JQuery retrieving index on hasClass

jquery

Solution

`.hasClass` returns a boolean, you can filter the results of `.children` to those that have the `classname`-class and then get the index:

$(".class").children(".classname").index();

Problem

Is it possible to get the index on the first instance of a hasClass? For Example: ``` $(".class").children().hasClass('classname').index(); ``` Unfortunately this doesn't work.

Original source