Created
May 25, 2016 16:33
-
-
Save osben/84dd4cfe1e7571cc0b55c501e7b462d0 to your computer and use it in GitHub Desktop.
Узнаем index элемента на уровне списка
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.getIndex = function(){ | |
var $p=$(this).parent().children(); | |
return $p.index(this); | |
} | |
/* | |
// DEMO | |
ul | |
li | |
li | |
li.active | |
li | |
li | |
$('ul li.active').getIndex() // return 2 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment