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标准)

  • 相关阅读:
    小朋友的责任 转自点妈文集
    amazon.cn, 感觉不错
    团队作业1——团队展示&选题
    如何解决mysql中的账户添加后不能登录的问题
    目标检测中常见指标
    latex知识点
    考研复试建议
    论文写作经验
    Git
    Python编程知识
  • 原文地址:https://www.cnblogs.com/haimingpro/p/4165125.html
Copyright © 2011-2022 走看看