<!DOCTYPE html>
<html>
<head>
<title>base.html</title>
<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<p>自定义节点属性和js读取自定义节点属性</p>
<p>1.静态自定义节点属性和js读取自定义节点属性</p>
<div id="setProperty" allowSeclect="ok">allowSeclect</div>
<p><button onclick="setP()" >点击测试</button></p>
<p>2.动态自定义节点属性和js读取自定义节点属性</p>
<div id="setProperty2">allowSeclect</div>
<p><button onclick="setP2()" >点击测试</button></p>
<script type="text/javascript">
function setP(){
var newArr=document.getElementById("setProperty").getAttribute("allowSeclect");
alert("newArr:"+newArr);
};
function setP2(){
var newArr2=document.getElementById("setProperty2");
newArr2.setAttribute("allowSeclect2","ok2");
var newArr2p=newArr2.getAttribute("allowSeclect2");
alert("newArr:"+newArr2p);
};
</script>
</body>
</html>
转载于:https://my.oschina.net/craftsdream/blog/638203