javascript - Text box focus not working -
javascript - Text box focus not working -
i trying focus text box programatically
code:
<input></input> <div id="click">click</div> $(document).ready(function(){ $("#click").live("click",function() { var inputbox=$(this).prev(); $(inputbox).focus(); } });
here fiddle http://jsfiddle.net/kwlf6/
demo
try code,
important - include jquery reference(in fiddle actual code)
.live()
deprecated of jquery 1.7, utilize .on()
instead.
add appropriate closing paranthesis in each function. (always seek check code errors through browser console)
$(document).ready(function(){ $("#click").on("click",function(){ $(this).prev().focus(); }); });
javascript jquery
Comments
Post a Comment