/ Published in: JavaScript
Useful if you want to manipulate/style/remove items after a given index count.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//HTML <div>Index 0</div> <div>Index 1</div> <div>Index 2</div> <div>Index 3</div> <div>Index 4</div> //SCRIPT $(document).ready(function(){ //get the number of DIV's var divCount = $('div').length; //check to see if the count is greater than 3 if (divCount > 3) { //count starts at zero (0, 1, 2...) $('div:gt(2)').css('background','darkOrange'); } });//jQuery
URL: http://marioluevanos.com/playground/Select%20Lenght%20of%20Elements/