Jquery to detect identical class and text for tab navi

假如想象 提交于 2019-12-02 17:30:29

问题


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:


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

should be

$('ul.slideMove li.'+sharedata).fadeIn('slow');


来源:https://stackoverflow.com/questions/7169724/jquery-to-detect-identical-class-and-text-for-tab-navi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!