jQuery Selector How to - Find certain child element








Question

We would like to know how to find certain child element.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.parent {<!--  w  w w  . j  a v  a 2  s  . co  m-->
  background: red;
  margin: 20px;
  padding: 20px;
}

.child {
  background: blue;
  margin: 20px;
  padding: 20px;
}

.parent:hover .child {
  background: yellow;
}
</style>
</head>
<body>
  <div class="parent">
    <div class="child"></div>
  </div>
  <div class="parent">
    <div class="child"></div>
  </div>
</body>
</html>

The code above is rendered as follows: