Add mouse over action event handler for all buttons returned from getElementsByTagName - Javascript DOM Event

Javascript examples for DOM Event:onmouseout

Description

Add mouse over action event handler for all buttons returned from getElementsByTagName

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//from  www . j a v  a2s  .  c om
var buttons = document.getElementsByTagName("button");
for (var i=0; i < buttons.length; i++)
{
  buttons[i].onmouseover = function()
  {
    console.log(buttons[i].title);
  }
}
    });

      </script> 
   </head> 
   <body> 
      <button title="hello this is a title">Hover me</button>  
      <button title="hello this is a title 2">Hover me</button>  
      <button title="hello this is a title 3">Hover me</button>  
      <button title="hello this is a title 4">Hover me</button>  
      
   </body>
</html>

Related Tutorials