Search code examples
javascriptjqueryfocus

Set focus to dynamically created DIV using JavaScript or jQuery


I have created

Generated code : 

<div id="showInfo_1" style="display: none">
--info 1
</div>

<div id="showInfo_2" style="display: none">
--info 2
</div>

jQuery : $('showInfo_2').focus();

This works fine in Chrome but not in IE.

What can I try next?


Solution

  • I just added return false in the onclick and it started working fine the way I expected.