So I have this PHP code
</div>
<div id="topmusicartisttitle">Top 5 Music Artist</div>
<div class="edit"><a href="" name="topartistsedit">edit</a></div>
<div id="topmusicartistlist">
<ul>
...
that basically passes a list of stuff and I want to be able to click on this a href in javascript but I don't want it to go anywhere I just want to catch the click and handle it. So to start I have:
$('a[name=birthdayedit').live('click',function(e){
e.preventDefault();
});
But this doesn't seem to work. I checked firebug and the href and the name are there (obviously), but the click isn't registered in Javascript and it still redirects. I assume live is the function to use since this is pretty much dynamically created content. Any one know what I'm doing wrong?
return false;in your click handler?birthdayeditnamed field in your snippet, and you're missing the closing]in the jquery selector.$('a[name=birthdayedit')is an error. Compare with$('a[name=birthdayedit]').$('a[name=birthdayedit'). Also, the name there doesn't match the name on your HTML!