jQuery,通过使用某些模式的ID隐藏div标签 [英] jquery, hiding div tags by using id of certain patterns
本文介绍了jQuery,通过使用某些模式的ID隐藏div标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经盯着这个看了一个小时,不确定这个语法有什么问题:
I have been staring at this for one hour and not sure what is wrong with this syntax:
jQuery.each(ARRAY_SUB_METRICS_HIDE, function() {
var VALUE = this;
\$("div[id^='reportdate-'" + VALUE + "]").hide();
alert(VALUE);
});
我的div标签没有隐藏,例如VALUE = 9--0--2,而我的id标签为id ="9--0--2--3"
my div tags are not hiding , example VALUE = 9--0--2 while i have div tags with id="9--0--2--3"
推荐答案
您必须移动单引号字符:
You have to move the single-quote character:
\$("div[id^='reportdate-" + VALUE + "']").hide();
当前,最终选择器的外观类似于$("div[id^='reportdate-'902]")
(注意引号错误).
Currently, your final selector looks like $("div[id^='reportdate-'902]")
(notice the wrongly placed quote).
这篇关于jQuery,通过使用某些模式的ID隐藏div标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文