<button id="button-1">Button 1</button>

<button id="button-2">Button 2</button>


<script>

// Get the buttons

var button1 = document.getElementById('button-1');

var button2 = document.getElementById('button-2');


// Attach click event listeners to the buttons

button1.addEventListener('click', logButtonText);

button2.addEventListener('click', logButtonText);


function logButtonText(event) {

  // Get the text of the button that was clicked

  var buttonText = event.target.innerText;


  console.log(buttonText);

}

</script>


Comments

Popular posts from this blog

Attack on Titan Final Episode Released! Dub Coming Soon

Understanding Entropy Calculation for Multiple Massage Signals

Understanding the Benefits of OZIVI Bundle for Mental Health