make focusable element unfocusable on webkit
- by Bill Keese
When a node has a tabIndex setting (other than -1), clicking it will give it focus. Removing the tabIndex setting should stop that behavior, so that clicking has no effect.
However, on webkit, once a node has a tabIndex, even after tabIndex is removed, the node can still be clicked and focused. Setting tabIndex=-1 also has the same click problem.
Anyone know a workaround to this problem?
<div id="one">one (no initial tabindex)</div>
<div id="two" tabindex=0>two (initially tabindex=0)</div>
<button type=button onclick="document.getElementById('one').setAttribute('tabindex', 0)">set tabindex on first div</button>
<button type=button onclick="document.getElementById('one').removeAttribute('tabindex', 0)">remove tabindex on first div</button>
<button type=button onclick="document.getElementById('two').removeAttribute('tabindex', 0)">remove tabindex on second div</button>
<button type=button onclick="document.getElementById('one').setAttribute('tabindex', -1)">set tabindex=1 on first div</button>
<button type=button onclick="document.getElementById('two').setAttribute('tabindex', -1)">set tabindex=1 on second div</button>