jquery andSelf() method


  Translation results:

and

英[ənd] 美[ənd, ən,ænd]

conj.And; and, with; so, then; therefore

self

英[self] 美[sɛlf]

n.Oneself;oneself;nature;self-interest

adj.unified; pure; single

vt. To self-fertilize; to cause inbreeding

vi. To self-fertilize

jquery andSelf() methodsyntax

Function: add() method adds the previous set of elements in the stack to the current set.

Syntax: .andSelf()

jquery andSelf() methodexample

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<style>
  p, div { margin:5px; padding:5px; }
  .border { border: 2px solid red; }
  .background { background:yellow; }
</style>
</head>
<body>
  <div>
    <p>First Paragraph</p>
    <p>Second Paragraph</p>
  </div>
<script>
    $("div").find("p").andSelf().addClass("border");
    $("div").find("p").addClass("background");
</script>
</body>
</html>
Run instance »

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

Home

Videos

Q&A