jquery children() method


  Translation results:

children

English [ˈtʃɪldrən] US [ˈtʃɪldrən]

n. Children; children (plural of child); knees; children

jquery children() methodsyntax

Function: The children() method returns all direct child elements of the selected element.

Syntax: .children(selector)

Parameters:

ParameterDescription
selector String value, containing the selector expression of the matching element.

jquery children() methodexample

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<style>
  body { font-size:16px; font-weight:bolder; }
  p { margin:5px 0; }
</style>
</head>
<body>
  <div>
    <span>Hello</span>
    <p class="selected">Hello Again</p>
    <div class="selected">And Again</div>

    <p>And One Last Time</p>
  </div>
<script>$("div").children(".selected").css("color", "blue");</script>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations

Home

Videos

Q&A