I’m learning jQuery and can’t figure this out:
Here’s the HTML
<a id="myid" name="myid" href="stub">click here</a>
and the jquery snippet:
$("#myid").click(function() {
alert('Hello from click');
});
Yet when I click on the link no alert displays. Something basic no doubt, What could I be doing wrong?
Thanks
I figured it out, file this under “learning jQuery”.
The hyperlink html was being loaded into a div via load() by clicking on a button after the document had loaded.
Fine, but the problem was that I was binding the event handler to the hyperlink before the element was created. Having used inline onlcick() for so long, it took me a while to figure it out the jQuery/Ajax way.
Thanks for the suggestions.