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>