zoukankan      html  css  js  c++  java
  • JS_attr函数

    /*
    * 考虑到getAttribute(),在IE6,7下对class有兼容性问题所以使用getAttributeNode();
    * removeNamedItem(),在IE6,7下动态添加属性后,表现异常.所以使用removeAttribute();
    */
    <
    div title="hello" id="main" dir="rtl" mytitle="whoat">my!</div> <script type="text/javascript"> var attr = function(ele,name,value){ if(!ele) return; if(!!value){ var _att = document.createAttribute(name); _att.nodeValue = value; ele.setAttributeNode(_att); return; } if(!!ele.getAttributeNode(name)){ var _val = ele.getAttributeNode(name).nodeValue; return _val; }else{ return null; } } var removeAttr = function(ele,name){ if(!ele) return; switch(name){ case "class": case "className": ele.removeAttribute("class"); ele.removeAttribute("className"); break; default: ele.removeAttribute(name); } } var main = document.getElementById("main"); attr(main,"class","main"); removeAttr(main,"dir"); </script>
  • 相关阅读:
    systemtap没找到函数变量
    systemtap get var of the tracepoing
    如何在tracepoint上注册函数
    stap中的entry函数
    stap用法
    在submit_bio处使用stapn
    巴达努斯
    perf事件的切换
    perf原理再看
    内存回收的阈值
  • 原文地址:https://www.cnblogs.com/somesayss/p/2776502.html
Copyright © 2011-2022 走看看