I have a function that finds the index of the first visible child. It works but I’m wondering if there’s a faster/better way to do it:
var TheDiv = $('#' + TheDivID);
var CurrentIndex = 0;
TheDiv.children().each(function () {
if ($(this).is(':visible')) {
CurrentIndex = $(this).index();
break;
}
});
Thanks for your suggestions.
If
TheDivdoes already exists, add the selector in the.children()method, and use.index()to get the index of the element:Otherwise, use: