JQuery uses siblings to obtain all siblings of an element. For example, jquerysiblings

Source: Internet
Author: User

JQuery uses siblings to obtain all siblings of an element. For example, jquerysiblings

This document describes how jQuery uses siblings to obtain all its peers (siblings) of an element. We will share this with you for your reference. The details are as follows:

Siblings () is an API of the jQuery filtering class. It is used to search for all peer elements of an element (all siblings ).

<Div id = "contentHolder"> <input type = "button" value = "1" id = "button1"> </input> <input type = "button" value =" 2 "id =" button2 "> </input> <input type =" button "value =" 3 "id =" button3 "> </input> </div>

If you need to implement the following functions: When you click a button, the background color of the button changes to #88b828, and the background color of other buttons changes to #15b494. At this time, the siblings API is very useful and very simple.

$ (Function () {$ ("# contentHolder input [type = 'click']"). click (function () {certificate (this).css ("background", "#88b828"); Certificate (this).siblings(.css .css ("background", "#15b494 ");});})

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.