Use the siblings of jquery to get all siblings (siblings) elements of an element

Source: Internet
Author: User

Siblings () is an API for jquery filtering classes to find all sibling 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 on a button, the background color of the button becomes #88b828, the other button background color becomes #15b494. This time,siblings This API is very useful, but also very simple.

$ (function () {$ ("#contentHolder input[type= ' button ']"). Click (function () {$ (this). CSS ("Background", "#88b828"); $ ( This). Siblings (). CSS ("Background", "#15b494");})


Use the siblings of jquery to get all siblings (siblings) elements of an element

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.