日期:2014-05-16 浏览次数:20353 次
<body> <div id = "t"><input type = "hidden" id = "sss" value = "aaa"></div> </body> <script> var d = document.getElementById("sss").attributes["value"]; document.write(d.name); document.write(d.value); //显示value aaa </script>
<body> <div id = "t"><input type = "hidden" id = "sss" value = "aaa"></div> </body> <script> var d = document.getElementById("sss").getAttribute("value"); document.write(d); //显示 aaa </script>
<body> <div id = "t"><input type = "hidden" id = "sss" value = "aaa"></div> </body> <script> var d = document.getElementById("sss").setAttribute("good","hello"); alert(document.getElementById("t").innerHTML) </script>
<body> <div id = "t"><input type = "hidden" id = "sss" value = "aaa"></div> </body> <script> var d = document.createAttribute("good"); document.getElementById("sss").setAttributeNode(d); alert(document.getElementById("t").innerHTML) </script>
<body> <div id = "t"><input type = "hidden" id = "sss" value = "aaa"></div> </body> <script> var d = document.getElementById("sss").removeAttribute("value"); alert(document.getElementById("t").innerHTML) </script>
<body> <div id = "t"><input type = "hidden" id = "sss" value = "aaa"></div> </body> <script> var d = document.getElementById("sss").getAttributeNode("value"); document.write(d.name); document.write(d.value); //显示 value aaa </script>
<body> <div id = "t"><input type = "hidden" id = "sss" value = "aaa"></div> </body> <script> var d = document.createAttribute("good"); document.getElementById("sss").setAttributeNode(d); alert(document.getElementById("t").innerHTML); </script>
<body> <div id = "t"><input type = "hidden" id = "sss" value = "aaa"></div> </body> <script> var d = document.getElementById("sss").getAttributeNode("value") document.getElementById("sss").removeAttributeNode(d); alert(document.getElementById("t").innerHTML); </script>