在javascript中,怎样声明一个变量,使改变量的值等于id为jkl的div标签的kkk属性的值,即:<div id="jkl" kkk="未定义"></div>
<!DOCTYPE html>
<html>
<head>
<title> New Document </title>
<meta name="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="idd" class="classes">
</div>
</body>
</html>
<script type="text/javascript" language="javascript">
window.onload = function() {
alert(document.getElementById("idd").getAttribute('class'));
}
</script>
<html>
<head>
<title> New Document </title>
<meta name="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="idd" class="classes">
</div>
</body>
</html>
<script type="text/javascript" language="javascript">
window.onload = function() {
alert(document.getElementById("idd").getAttribute('class'));
}
</script>
温馨提示:答案为网友推荐,仅供参考
第1个回答 2015-04-24
var att;
att=document.getElementById('jkl').getAttribute("kkk");
att=document.getElementById('jkl').getAttribute("kkk");