zoukankan      html  css  js  c++  java
  • js:getAttribute

    		function setAll(elemName) {
                var loves = document.getElementsByName(elemName);
                 for (var i = 0; i < loves.length; i++) {
                     loves[i].checked = true;
                 }
             }
    
             //全不选函数
             function setNo(elemName) {
                 var loves = document.getElementsByName(elemName);
                 for (var i = 0; i < loves.length; i++) {
                     loves[i].checked = false;
                 }
             }
     
             //反选
             function setOthers(elemName) {
                 var loves = document.getElementsByName(elemName);
                 for (var i = 0; i < loves.length; i++) {
                     if (loves[i].checked == false)
                         loves[i].checked = true;
                    else
                         loves[i].checked = false;
                 }
             }
             
             //全选/全不选操作
             function setAllNo(elemId, elemName){
                 var box = document.getElementById(elemId);
                 var loves = document.getElementsByName(elemName);
                 if(box.checked == false){
                    for (var i = 0; i < loves.length; i++) {
                        loves[i].checked = false;
    					var hiddenElemId =  loves[i].getAttribute("pphffid");
    					var hiddenElemObj = document.getElementById(hiddenElemId);
    					hiddenElemObj.value = 'N';
                     }
                 }else{
                     for (var i = 0; i < loves.length; i++) {
                         loves[i].checked = true;
    					 var hiddenElemId =  loves[i].getAttribute("pphffid");
    					 var scitegic_checkedvalue = loves[i].getAttribute("scitegic_checkedvalue");
    					var hiddenElemObj = document.getElementById(hiddenElemId);
    					hiddenElemObj.value = scitegic_checkedvalue;
                         }
                 }
             }
    
    <!DOCTYPE html>
    <html>
    <body>
    getAttribute 功能演示
    
    请阅读 <a href="/jsref/dom_obj_attributes.asp" target="_blank">Attr 对象</a>,
    
    <p id="demo">请点击按钮来显示上面这个链接的 target 属性值。</p>
    
    <button onclick="myFunction()">试一下</button>
    
    <script>
    function myFunction()
    {
    var a=document.getElementsByTagName("a")[0];
    document.getElementById("demo").innerHTML=a.getAttribute("href");
    }
    </script>
    
    </body>
    </html>
    
  • 相关阅读:
    我的美丽的家乡
    童谣
    有点激动,久违的老家。
    5月8我要发,一个值得纪念的日子
    奥运会上,菲尔普斯拿了8金后,各国的反应....
    2岁半的儿子
    【题解】 「联合省选2020」冰火战士 线段树+二分 LOJ3299
    【题解】 「NOI2017」整数 线段树+二分+压位 LOJ2302
    500 OOPS: cannot change directory:/home/
    Customized Alerts for SQL Server Transactional Replication
  • 原文地址:https://www.cnblogs.com/lab-zj/p/14714542.html
Copyright © 2011-2022 走看看