I have the following script. At the moment it selects the 3rd item in my list and gives it no margin. The problem is it only does this once, is there a way I can make it happen to every 3rd item in the list? I tried using .each but I couldn’t get it to work successfully.
<script>
$(document).ready(function() {
$("#contentlist li:eq(2)").css({marginRight: '0'});
});
</script>
The
nth-childpseudo-class using3ncan do this.Demo: http://jsfiddle.net/ThinkingStiff/gjvpR/
HTML:
Script:
Output: