mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-19 15:30:24 +00:00
53 lines
No EOL
2.6 KiB
HTML
53 lines
No EOL
2.6 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>:lt() Selector</h1>
|
|
|
|
</div>
|
|
<div data-role="content" data-theme="c" id="lt1">
|
|
<h2 class="jq-clearfix roundTop section-title">
|
|
<span class="name">lt</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(':lt(index)')</h4>
|
|
<ul class="signatures"><li><dl class="arguments">
|
|
<dt>index</dt>
|
|
<dd>Zero-based index.</dd>
|
|
</dl></li></ul>
|
|
<p class="desc"><strong>Description: </strong>Select all elements at an index less than index within the matched set.</p>
|
|
<div class="longdesc">
|
|
<p><strong>index-related selectors</strong></p>
|
|
<p>The index-related selectors (including this "less than" selector) filter the set of elements that have matched the expressions that precede them. They narrow the set down based on the order of the elements within this matched set. For example, if elements are first selected with a class selector (<code>.myclass</code>) and four elements are returned, these elements are given indices 0 through 3 for the purposes of these selectors.</p>
|
|
<p>Note that since JavaScript arrays use <em>0-based indexing</em>, these selectors reflect that fact. This is why <code>$('.myclass:lt(1)')</code> selects the first element in the document with the class <code>myclass</code>, rather than selecting no elements. In contrast, <code>:nth-child(n)</code> uses <em>1-based indexing</em> to conform to the CSS specification.</p>
|
|
</div>
|
|
<h3>Example:</h3>
|
|
<div id="entry-examples" class="entry-examples"><div id="example-0">
|
|
<h4><span class="desc">Finds TDs less than the one with the 4th index (TD#4).</span></h4>
|
|
<pre><code class="example demo-code"><!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
|
</head>
|
|
<body>
|
|
<table border="1">
|
|
|
|
<tr><td>TD #0</td><td>TD #1</td><td>TD #2</td></tr>
|
|
<tr><td>TD #3</td><td>TD #4</td><td>TD #5</td></tr>
|
|
|
|
<tr><td>TD #6</td><td>TD #7</td><td>TD #8</td></tr>
|
|
</table>
|
|
<script>$("td:lt(4)").css("color", "red");</script>
|
|
</body>
|
|
</html></code></pre>
|
|
<h4>Demo:</h4>
|
|
<div class="demo code-demo"></div>
|
|
</div></div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body></html> |