1

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Joe
  • 4,460
  • 19
  • 60
  • 106

2 Answers2

2

Attempting to set focus to a hidden element causes an error in Internet Explorer. Take care to only use .focus() on elements that are visible. To run an element's focus event handlers without setting focus to the element, use .triggerHandler( "focus" ) instead of .focus().

from: https://api.jquery.com/focus/

Grant Foster
  • 722
  • 2
  • 11
  • 21
0

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

halfer
  • 19,824
  • 17
  • 99
  • 186
Joe
  • 4,460
  • 19
  • 60
  • 106