B
B
Berry902015-11-16 15:49:12
JavaScript
Berry90, 2015-11-16 15:49:12

How to do something similar to the hover property in javascript for a group of elements?

I started to study js, for understanding I want to do hover(css) on js, I could do it for one element through onmouse... reacted to onmouse... ?

<!DOCTYPE html>
<html lang="ru">
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="style.css">
  <title>Document</title>
</head>
<body>
  <table id="box">
    <tr>
      <td>first</td>
    </tr>
    <tr>
      <td>second</td>
    </tr>
    <tr>
      <td>third</td>
    </tr>
    <tr>
      <td>fourth</td>
    </tr>
    <tr>
      <td>fifth</td>
    </tr>


  </table>
<script src="script.js"></script>
</body>
</html>

var a;
a = document.getElementById("box").children;
a.onmouseover = function() {
  this.style.backgroundColor = "green";
}

did it didn't work

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2015-11-16
@Berry90

Just like on one, only in a cycle.

M
Murat Atila, 2015-11-16
@TheExplay

Do you want all elements in a row to respond to the hover of one element?
Hang an event on the row itself and do what you want with the child elements.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question