Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #20223

    Hello again,

    Im trying to add unique classes to my “sub-menu” class… By inputing this in the bottom of the avia.js file…

    (function($){

    $(‘ul.sub-menu’).addClass (function(idx) {

    return “item-” + idx;

    });

    });

    })(jQuery);

    But it doesent do didely…

    Am I implementing it wrong? Or should I use a different approach?

    Kind regards,

    Richard

    #106744

    Hey!

    Try following code:

    jQuery("#top ul.sub-menu").each(function(i){
    jQuery(this).addClass("item-" + (i+1));
    });

    Regards,

    Peter

    #106745

    Hello dude!

    Thanks for the quick reply! I have pasted your code in the bottom of the avia.js file, was that correct? Because nothing happens…

    Kind regards,

    Richard

    #106746

    Hey!

    Maybe you need to wrap it into a document ready function like:

    jQuery(document).ready(function() {
    jQuery("#top ul.sub-menu").each(function(i){
    jQuery(this).addClass("item-" + (i+1));
    });
    });

    Regards,

    Peter

    #106747

    Dude! Youre daaaa booooooomb!! Works great! Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Give class "sub-menu" an unique class..’ is closed to new replies.