jquery - How to avoid loosing focus on click of anchor tag? -
i have input type text element , anchor element, don't want loose focus on click of anchor tag if focus on input text element. have tried following not work.
html:
<input type = 'text' value='click here first' /> <a href='javascript:void(null);' id='nothing'>do nothing</a> jquery code:
$('#nothing').bind('click', function(e){     e.preventdefault(); }) above not work me. can tell me missing here?
i have faced similar problem try using 'mousedown' instead of click event.
here demo
<input type = 'text' value='click here first' /> <a href='javascript:void(null);' id='nothing'>clicking not loose focus input field!</a>  $('#nothing').bind('mousedown', function(e){     e.preventdefault(); }) 
Comments
Post a Comment