hasAttribute() 예제
<button id="btn" onclick="homzzang()">클릭</button> <p id="demo"></p> <script> function homzzang() { var x = document.getElementById("btn").hasAttribute("onclick"); document.getElementById("demo").innerHTML = x; } </script> 결과보기
<button id="btn" onclick="homzzang()">클릭</button>
<p id="demo"></p>
<script>
function homzzang() {
var x = document.getElementById("btn").hasAttribute("onclick");
document.getElementById("demo").innerHTML = x;
}
</script>
결과보기