Reputation: 7121
I want to print the attribute of isChecked
:
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction(){
alert(document.getElementById('myId').isChecked);
}
</script>
</head>
<body>
<img id="myId" isChecked="0"/>
<br>
<button onclick="myFunction();">Click me</button>
</body>
</html>
it prints me undefined
any help appreciated!
Upvotes: 0
Views: 128
Reputation: 800
try,
alert(document.getElementById('myId').getAttribute("isChecked"));
Upvotes: 1
Reputation: 64296
Use getAttribute
alert(document.getElementById('myId').getAttribute("isChecked"));
Upvotes: 9