Jquery to detect identical class and text for tab

2019-03-05 03:59发布

Does anyone have experience detecting identical text(); and class?

here is my current code to

    $("ul.nav li").click(function() {

    $('ul.slideMove li').fadeOut('slow');

    var sharedata = $(this).text();
    $('ul.slideMove li[class = "'+sharedata+'" ]').fadeIn('slow');

});

the final goal will be to have tabbed navigation. When the text in ul.nav li is the same as a class within the the dynamic container, fadeIn(). On initial load, only one container will be visible then hide and show another container after you click the next li

If anyone can point me in the right direction i would really apprecieate it.

Currently, it hides all the containers after i click any li. Im not clear on how I can detect if the class equals the text var.

Thanks so much!

1条回答
\"骚年 ilove
2楼-- · 2019-03-05 04:23
$('ul.slideMove li[class = "'+sharedata+'" ]').fadeIn('slow'); 

should be

$('ul.slideMove li.'+sharedata).fadeIn('slow');
查看更多
登录 后发表回答