html中div擷取焦點,去掉input div等擷取焦點時候的邊框

來源:互聯網
上載者:User

標籤:

經測試只有在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等擷取焦點時候的邊框

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.