Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Top World Wide Web Interviews:Action ScriptAJAXBasic InternetBloggingCascading Style Sheet CSSCSS3DHTMLDomain Name System (DNS)EcommerceHTMLHTML5JavaScriptjQueryjQuery KnockoutJSONJSONPUser Interface DesignerVBScriptW3CWeb 2.0 TechnologiesWeb 3.0 TechnologiesWeb BuildingWeb DevelopersWeb QualityWeb SecurityWeb SemanticWebmaster
Copyright © 2018. All Rights Reserved
jQuery Interview Question:
Define .siblings() method in jQuery?
Submitted by: AdministratorWhen we want to fetch siblings of every elements in the set of matched elements then we can use siblings() method.
We filter the elements fetched by an optional selector.
Syntax : .siblings( [selector])
"selector" is the selector expression which specify the matched elements.
For example:
<ul>
<li> item 1 </li>
<li id="second_item"> item 2 </li>
<li class="myitem"> item 3 </li>
<li class="myitem"> item 4 </li>
</ul>
Now we want to find the siblings of the element of id "second_item" and change the text color to Blue :
$('li.second_item').siblings().css('color','blue');
If we want specific sibling elements for example the elements having class "myitem" then we can pass a optional selector:
$('li.second_item').siblings('.myitem').css('color','blue');
Submitted by:
We filter the elements fetched by an optional selector.
Syntax : .siblings( [selector])
"selector" is the selector expression which specify the matched elements.
For example:
<ul>
<li> item 1 </li>
<li id="second_item"> item 2 </li>
<li class="myitem"> item 3 </li>
<li class="myitem"> item 4 </li>
</ul>
Now we want to find the siblings of the element of id "second_item" and change the text color to Blue :
$('li.second_item').siblings().css('color','blue');
If we want specific sibling elements for example the elements having class "myitem" then we can pass a optional selector:
$('li.second_item').siblings('.myitem').css('color','blue');
Submitted by:
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.