Reputation: 106
Hi I am creating a search box using li and input text.
I want to load a page based on the selected results of search box, whenever the search result is clicked.
Search result is in form of li on which I am binding the below click event.
Somehow the following click event is not firing
$("li").click(function(){
alert("HI");
alert($(this).text());
return false;
});
See the JS Fiddle for more details:
http://jsfiddle.net/amitsant/2zhk209v/3/
Upvotes: 3
Views: 1724
Reputation: 16150
Just listen to mousedown
instead of click
. This happens because click waits for the mouseup
event, that never is triggered because blur
comes first, hiding the panel.
$("li").mousedown(function(){
...
Working fiddle: http://jsfiddle.net/3umj3fup/
Upvotes: 5