I wanted to save all the id’s with the class inactive in an array , then i want to itereate through the array and check for particular values , for instance the inactive ids will be like : menu-level-0-0-1 , menu-level-0-0-2, menu-level-0-1-3
I want to save all these id’s and then split it like:
var inactiveID = $('.inactive').attr('id')
var splitInactive = inactiveID.split('-');
var inactiveParentCategoryid = splitInactive[3];
var inactiveCategoryid = splitInactive[4];
After splitting it do some checking and if the check pass add the class:
if (parentCategoryid == inactiveCategoryid) {
//$('.menu-level-0-0-'+ inactiveCategoryid).css('background-image', 'url(/Themes/DarkOrange/Content/images/cat-ul-active.png)');
$('.inactive ').css('color', 'white !Important');
}
The active ids will only be one , thats why i dont need an array and can easily be accessible by :
var activeId = $('.active').attr('id')
var split = activeId.split('-');
var parentCategoryid = split[3];
var categoryid = split[4];
Can any one help me in sorting out this issue in a correct way or any other suggestions will be highly appreciated.
You might want to use
.each()