Pass <button> element object into click event handler function - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Pass <button> element object into click event handler function

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head></head>
   <body translate="no"> 
      <button onclick="confirmDelete(this)" value="True" name="deleteButton">Delete </button> 
      <script>
      function confirmDelete(elem) {

    var theValue = elem.value;/*  www  .jav  a  2s. c o  m*/
    if (theValue == "True") {
        console.log("True");
    } else {
        console.log("False");
    }
}
    
      </script>  
   </body>
</html>

Related Tutorials