상세 컨텐츠

본문 제목

how to get Button id in JavaScript ?

개발생활/JavaScript

by 한국인맛집 2019. 1. 3. 14:12

본문

반응형

Click Button Get tag id 




this Code!

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>


<body>
  <button class="btn" id="3" onClick="show(this.id)"> click Me</button>
</body>



</html>





<script >

 function show(btn_id){
    
    alert(btn_id);
  }

</script>


반응형

관련글 더보기