Javascript Focus Does Not Work On Dynamically Loaded Input Box
I have a HTML markup in a template which has input element. I load it via Ajax call and put in existing html using jQuery's $(selector).html(response). Basically it is a pop up box
Solution 1:
if you are using jquery
then you can use .on()
on dynamically generated elements
$("#prescribe-input").on( "focus", function() {
//do what ever you want
});
Solution 2:
You should do this in the callback function:
$(selector).html(response, function(){
$("#prescribe-input").focus();
})
Post a Comment for "Javascript Focus Does Not Work On Dynamically Loaded Input Box"