Reputation: 135
I'm using
$("#divVZITab").attr("tabindex",-1).focus();
On page load I want divVZITab
to become the focus, it is in the center
of page. So when page loads IE should automatically scroll to the center of the page & focus on the div.
But it is not working.
Upvotes: 2
Views: 17008
Reputation: 76
$("#divVZITab").focus()
or
document.getElementById('divVZITab').focus();
Upvotes: 1
Reputation: 2684
As you mentioned IE, I think that is the issue because I tried in jsfiddle and works fine. I tried in IE with tabindex="-1" and does not work but for positive (+ve) value of tabindex="1" it works. BTW run script after the DOM is ready.
<div id='divVZITab' tabindex="1">Test</div>
document.getElementById('divVZITab').focus();
Upvotes: 4
Reputation: 763
Is it possible to focus on a <div> using javascript focus() function?
please refer to second answer in the above link.
Hope that's the same stuff you trying to achieve.
Upvotes: 0