开发者

I want to use a text string as my JQuery selector, how do I do that?

$("ul.tabs li").click(function() {
    var tab = $(this).attr("id");
    var tabState = $开发者_开发技巧(this).is(".selected");
    var showThis = ".selector-" + tab; 

    if (tabState == true) {
        $(NeedToConvertshowThisIntoObject).fadeIn(100);
    }
    else {
        alert(Something);
    }
});

Thanks!


You don't need to convert anything. The below line will work perfectly if the selector is matched.

$(showThis).fadeIn(100);


$(showThis) should do it:

$(showThis).fadeIn(100);


You can use $(showthis) instead $(NeedToConvertshowThisIntoObject) for example: $(showThis).fadeIn(100);

Best Regards Li Satisfy

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜