Skip to content Skip to sidebar Skip to footer

Add Location.hash On A Jquery Search

I have this script that will display results $('#searchList li').bind('click', function() { var li = $(this); var li_val = li.text()

Solution 1:

You are selecting a li-element and attach the click event to that. This li element obviously doesn't have a href-attribute, and therefore it is undefined. Attach it to the underlying a element instead:

$('#searchList li a').click(function(){
  //...
});

Post a Comment for "Add Location.hash On A Jquery Search"