Home > Web Front-end > JS Tutorial > Example analysis of siblings usage in jQuery_jquery

Example analysis of siblings usage in jQuery_jquery

WBOY
Release: 2016-05-16 15:23:40
Original
1521 people have browsed it

The examples in this article describe the usage of siblings in jQuery. Share it with everyone for your reference, the details are as follows:

The so-called siblings, the English translation is brother nodes. So the name implies, it is to get the sibling nodes of a certain element (excluding itself).

<html>
<head>
 <script type="text/javascript" src="/jquery/jquery.js"></script>
</head>
<body>
<ul>
  <li>li1</li>
  <li>li2</li>
  <li id="li3">li3</li>
  <li>li4</li>
  <li>li5</li>
</ul>
<script>
  $("#li3").siblings("li").css("backgroundcolor", "yellow");
</script>
</body>
</html>

Copy after login

We also know,

Copy code The code is as follows:
$("#li3").siblings("li").css(" backgroundcolor", "yellow")

in this case can be written as

Copy code The code is as follows:
$("#li3").siblings().css("backgroundcolor", "yellow")

By default, it takes the same sibling element as itself.

I hope this article will be helpful to everyone in jQuery programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template