zoukankan      html  css  js  c++  java
  • html5与css交互 API 《一》classList

    用过jquery的朋友都知道,jquery提供的方法中(3个)可以很方便的为指定的节点添加、删除类选择器,即addClass、removeClass、toggleClass。具体的用法我这里就不谈了,不了解的请移步[jquery官方网站][1]
    
    
    下面我们一起看看html5中classList对象的基本属性
    

    document.createElement("p").classList
    {
    length : 0,
    add : function add() { [native code] } ,
    contains : function contains() { [native code] } ,
    item : function item() { [native code] } ,
    remove : function remove() { [native code] } ,
    toString : function toString() { [native code] } ,
    toggle : function toggle() { [native code] }
    }

    从上面的对象中,有三个基本方法是和jquery中相应的方法是一一对应的,即add、remove、toggle,这三个方法和jquery中用法一直就不说了。
    另外:
    contains方法是用来判断指定的类选择器是否存在,存在则返回true,否则返回false
    item方法是用来取出指定索引位置处的类选择器。
    
    浏览器兼容性
    目前高版本的浏览器中已得到完美的支持Chrome、IE10+、Firefox
    
  • 相关阅读:
    KMP
    Trie 树
    Miller-Rabin质数测试
    快速幂
    Matlab 对图片的二值化处理
    huffman tree
    hdu5512-Pagodas
    迷宫
    poj2488-A Knight's Journey【DFS】
    linux操作
  • 原文地址:https://www.cnblogs.com/10manongit/p/12988239.html
Copyright © 2011-2022 走看看