mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-23 01:10:25 +00:00
65 lines
No EOL
2.1 KiB
HTML
65 lines
No EOL
2.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang='en'><head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1"><meta http-equiv='content-type' content='text/html; charset=UTF-8' /></head><body>
|
|
<div data-role="page">
|
|
<div data-role="header">
|
|
<h1>:only-child Selector</h1>
|
|
|
|
</div>
|
|
<div data-role="content" data-theme="c" id="only-child1">
|
|
<h2 class="jq-clearfix roundTop section-title">
|
|
<span class="name">only-child</span> selector</h2>
|
|
<div class=" entry-details">
|
|
<h4 class="name">
|
|
<span class="versionAdded">version added: <a href="/version/1.1.4/">1.1.4</a></span>jQuery(':only-child')</h4>
|
|
<p class="desc"><strong>Description: </strong>Selects all elements that are the only child of their parent.</p>
|
|
<div class="longdesc"><p>If the parent has other child elements, nothing is matched.</p></div>
|
|
<h3>Example:</h3>
|
|
<div id="entry-examples" class="entry-examples"><div id="example-0">
|
|
<h4><span class="desc">Finds the button with no siblings in each matched div and modifies look.</span></h4>
|
|
<pre><code class="example demo-code"><!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<style>
|
|
|
|
div { width:100px; height:80px; margin:5px; float:left; background:#b9e }
|
|
</style>
|
|
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
|
</head>
|
|
<body>
|
|
<div>
|
|
<button>Sibling!</button>
|
|
<button>Sibling!</button>
|
|
</div>
|
|
|
|
<div>
|
|
<button>Sibling!</button>
|
|
</div>
|
|
<div>
|
|
None
|
|
</div>
|
|
|
|
<div>
|
|
<button>Sibling!</button>
|
|
<button>Sibling!</button>
|
|
<button>Sibling!</button>
|
|
|
|
</div>
|
|
<div>
|
|
<button>Sibling!</button>
|
|
</div>
|
|
<script>$("div button:only-child").text("Alone").css("border", "2px blue solid");</script>
|
|
</body>
|
|
</html></code></pre>
|
|
<h4>Demo:</h4>
|
|
<div class="demo code-demo"></div>
|
|
<h4>Result:</h4>
|
|
<pre><code class="results">[ <li>Glen</li> ] </code></pre>
|
|
</div></div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body></html> |