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
精彩评论