Attach JQuery Click Event to Anchor Id
问题 I have an easy one SO. Why cant I attach a click event straight to an anchors Id? I should have pointed out that I am also using JQuery Mobile. <div id="foobarNavbar" data-role="navbar" style="display:none;"> <ul> <li><a id="foo" href="#foo" data-icon="plus">New Event</a></li> <li><a id="bar" href="#bar" data-icon="grid">Events</a></li> </ul> </div><!-- /foobarNavbar--> I am trying to attach a click event to foo. This doesn't work: $('#foo').bind('click', function(e) { e.preventDefault();