control-freak-ide/Control-Freak-Documentation/jQuery/docs/entries/lt-selector.json
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

1 line
2.1 KiB
JSON

{"name":"lt","type":"selector","title":":lt() Selector","deprecated":null,"removed":null,"desc":"Select all elements at an index less than <code>index</code> within the matched set.","categories":["selectors/basic-filter-selectors","selectors/jquery-selector-extensions","version/1.0"],"entries":[{"return":"","signatures":[{"sample":":lt(index)","added":"1.0","argument":{"desc":"Zero-based index.","name":"index","type":"Number"}},{"sample":":lt(-index)","added":"1.8","argument":{"desc":"Zero-based index, counting backwards from the last element. ","name":"-index","type":"Integer"}}],"examples":{"desc":"Give TDs less than the one with the 4th index (TD#4) a yellow background and TDs less than the one with -2nd index a red text color.","code":"\n$( \"td:lt(4)\" ).css( \"backgroundColor\", \"yellow\" );\n$( \"td:lt(-2)\" ).css( \"color\", \"red\" );\n","html":"\n<table border=\"1\">\n <tr><td>TD #0</td><td>TD #1</td><td>TD #2</td></tr>\n <tr><td>TD #3</td><td>TD #4</td><td>TD #5</td></tr>\n <tr><td>TD #6</td><td>TD #7</td><td>TD #8</td></tr>\n</table>\n"},"longdesc":"\n <p>\n <strong>index-related selectors</strong>\n </p>\n <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>\n <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>\n <p>Prior to jQuery 1.8, the <code>:lt(index)</code> selector did <em>not</em> accept a negative value for <code>index</code></p>\n "}],"slug":"lt-selector"}