How do I prevent jquery address from triggering a change?
I'm using jquery address to track changes with the browsers nav buttons and have hit a bump in the road. The plugin works great for simple html links but I have a dropdown menu that is triggering an address change when the parent node is clicked. The drop down menu looks like this:
<li id="messages"><a href="#" class="drop" >Messages</a>
<div class="drop2columns dropcontent">
<div class="col_2">
<ul>
<li><a id="msgs_received" href="#msgs_received">Inbox</a></li>
<li><a id=开发者_StackOverflow"msgs_sent" href="msgs_sent">Sent</a></li>
</ul>
</div>
</div>
</li>
When I click the "Messages" portion to trigger my dropdown the location is getting set to "/" (I would assume because my href="#")
Is there a way to ignore this onclick event?
I've been thinking about creating an onClick event that gets/sets the same URL so it doesn't trigger jqueries address change method. This seems more like a hack then a solution though. Any thoughts?
In your JS, try this:
$("#messages").bind("click", function(e){
e.preventDefault();
});
精彩评论