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

  • 相关阅读:
    吃喝玩乐AI黑科技
    容器的介绍
    java线程池
    2020牛客暑期多校训练营(第三场)
    zabbix5.0快速搭建
    prometheus中的alertmanage配置文件详解
    gitlab的api操作
    vim编辑器可视模式
    sql语句执行顺序详解
    sql连表查询练习题
  • 原文地址:https://www.cnblogs.com/haimingpro/p/4165125.html
Copyright © 2020-2023  润新知