標籤:
經測試只有在IE chrome才會在擷取焦點時有邊框
使用CSS
div{ outline:none;}DIV焦時間點事件詳解 --【focus和tabIndex】?
摘自:http://my.oschina.net/jgy/blog/131970
添加 tabindex=‘-1‘ 屬性;
預設:擷取不到焦時間點事件(blur)
<div class="wl-product" id="wl-product"></div>
可以擷取焦時間點事件(blur)
<div class="wl-product" id="wl-product" tabindex=‘-1‘></div>
首先看看w3c關於onfocus的部分:
The onfocus event occurs when an element receives focus either by the pointing device or by tabbing navigation.
This attribute may be used with the following elements: A, AREA, LABEL, INPUT, SELECT, TEXTAREA, and BUTTON.
當元素通過指定(點擊)或tab導航(Tabbing navigation)獲得焦點,onfocus事件就會觸發。
該屬性會使用在以下元素(就是說預設可以擷取焦點的元素):A, AREA, LABEL, INPUT, SELECT, TEXTAREA, and BUTTON.
div, frameSet, span, table, td.只有設定tableindex才能擷取焦點,但
IE預設能擷取焦點但不能tab導航
不同tabIndex值在tab order(Tabbing navigation)中的情況:
Objects with a positive tabIndex are selected in increasing iIndex order and in source order to resolve duplicates.
Objects with an tabIndex of zero are selected in source order.
Objects with a negative tabIndex are omitted from the tabbing order.
tabIndex值是正數的對象根據遞增的值順序和代碼中的位置順序來被選擇
tabIndex值是0的對象根據在代碼中的位置順序被選擇
tabIndex值是負數的對象會被忽略
html中div擷取焦點,去掉input div等擷取焦點時候的邊框