zoukankan      html  css  js  c++  java
  • DIV焦点事件

    div本来是没有focus和blur事件的。

    如果用div来模拟一个input标签,同时需要它和input一样响应focus和blur事件,

    就需要给他加上attribute:tabindex

    An element can have focus if the tabIndex property is set to any valid negative or positive integer.
    Elements that receive focus can fire the onblur and onfocus events as of Internet Explorer 4.0, and the onkeydown, onkeypress, and onkeyup events as of Internet Explorer 5.
    只要元素的tabIndex属性设置成任何有效的整数那么该元素就能取得焦点。元素在取得焦点后就能触发onblur,onfocus,onkeydown, onkeypress和onkeyup事件。
    
    不同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值是负数的对象会被忽略

    obj.style.outline  =   " none "

    如果获得焦点的时候出现虚线框可以这样去除。

    另外,focus并不会冒泡(w3c标准)

  • 相关阅读:
    win10右键在此处打开CMD
    练习1-20 编写程序detab,将输入中的制表符替换成适当数目的空格.
    编写一个程序,打印输入中单词长度的直方图.垂直方向
    王爽 汇编 实验14
    python 文件
    函数和方法
    python-格式化字符串
    MPC&MAGIC
    python-super1
    小知识点
  • 原文地址:https://www.cnblogs.com/haimingpro/p/4165125.html
Copyright © 2011-2022 走看看