mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-24 09:50:26 +00:00
70 lines
No EOL
2.9 KiB
HTML
70 lines
No EOL
2.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang='en'><head><meta http-equiv='content-type' content='text/html; charset=UTF-8' /></head><body>
|
|
<div class="ui-page">
|
|
<div class="ui-header">
|
|
<h1>Next Siblings Selector (“prev ~ siblings”)</h1>
|
|
<div class="entry-meta">Categories:
|
|
<span class="category"><a href="http://api.jquery.com/category/selectors/" title="View all posts in Selectors">Selectors</a> > <a href="http://api.jquery.com/category/selectors/hierarchy-selectors/" title="View all posts in Hierarchy">Hierarchy</a></span>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="entry selector" id="next siblings1">
|
|
<h2 class="jq-clearfix roundTop section-title">
|
|
<span class="name">next siblings</span> selector</h2>
|
|
<div class=" entry-details">
|
|
<h4 class="name">
|
|
<span class="versionAdded">version added: <a href="/version/1.0/">1.0</a></span>jQuery('prev ~ siblings')</h4>
|
|
<ul class="signatures"><li><dl class="arguments">
|
|
<dt>prev</dt>
|
|
<dd>Any valid selector.</dd>
|
|
<dt>siblings</dt>
|
|
<dd>A selector to filter elements that are the following siblings of the first selector.</dd>
|
|
</dl></li></ul>
|
|
<p class="desc"><strong>Description: </strong>Selects all sibling elements that follow after the "prev" element, have the same parent, and match the filtering "siblings" selector.</p>
|
|
<div class="longdesc"><p>The notable difference between (<code>prev + next</code>) and (<code>prev ~ siblings</code>) is their respective reach. While the former reaches only to the immediately following sibling element, the latter extends that reach to all following sibling elements.</p></div>
|
|
<h3>Example:</h3>
|
|
<div id="entry-examples" class="entry-examples"><div id="example-0">
|
|
<h4><span class="desc">Finds all divs that are siblings after the element with #prev as its id. Notice the span isn't selected since it is not a div and the "niece" isn't selected since it is a child of a sibling, not an actual sibling.</span></h4>
|
|
<pre><code class="example demo-code"><!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<style>
|
|
|
|
div,span {
|
|
display:block;
|
|
width:80px;
|
|
height:80px;
|
|
margin:5px;
|
|
background:#bbffaa;
|
|
float:left;
|
|
font-size:14px;
|
|
}
|
|
div#small {
|
|
width:60px;
|
|
height:25px;
|
|
font-size:12px;
|
|
background:#fab;
|
|
}
|
|
</style>
|
|
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
|
</head>
|
|
<body>
|
|
<div>div (doesn't match since before #prev)</div>
|
|
<span id="prev">span#prev</span>
|
|
<div>div sibling</div>
|
|
|
|
<div>div sibling <div id="small">div niece</div></div>
|
|
<span>span sibling (not div)</span>
|
|
<div>div sibling</div>
|
|
<script>$("#prev ~ div").css("border", "3px groove blue");</script>
|
|
</body>
|
|
</html></code></pre>
|
|
<h4>Demo:</h4>
|
|
<div class="demo code-demo"></div>
|
|
</div></div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body></html> |