Skip to content

Instantly share code, notes, and snippets.

@antiden
Created February 1, 2017 12:01
Show Gist options
  • Save antiden/94cf99b8c46773162ce8fa3542e7f28f to your computer and use it in GitHub Desktop.
Save antiden/94cf99b8c46773162ce8fa3542e7f28f to your computer and use it in GitHub Desktop.
Count elements and add Classes
/*Count*/
var $this = $('.page_content__content .menu > li');
if ($this.length == 1) {
$this.addClass('one');
} else if ($this.length == 2) {
$this.addClass('two');
} else if ($this.length == 3) {
$this.addClass('three');
} else if ($this.length == 4) {
$this.addClass('four');
} else if ($this.length == 5) {
$this.addClass('five');
} else if ($this.length == 6) {
$this.addClass('six');
} else if ($this.length == 7) {
$this.addClass('seven');
} else if ($this.length == 8) {
$this.addClass('eight');
} else if ($this.length == 9) {
$this.addClass('nine');
} else if ($this.length == 10) {
$this.addClass('ten');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment