我试图隐藏具有相同类名(float_form)的元素,但我也尝试使用下面的脚本来显示它们(所有的float_form类div最初都是隐藏的).我已经看了很多jquery解决方案,但我似乎无法让它们中的任何一个工作.
function show(a) {
var e = document.getElementById(a);
if (!e)
return true;
if (e.style.display == "none") {
e.style.display = "block"
} else {
e.style.display = "none"
}
return true;
}
?
Run Code Online (Sandbox Code Playgroud)
编辑:对不起,如果不清楚,我不打算使用Jquery(我知道这不是jquery).我正在寻找一种方法来使用javascript来识别不在style = display:none中的重复类名.在不影响show/hide ID元素的情况下,因为有一个以div id为键的循环.div的html如下所示,{item.ID}是while循环.
<div class="float_form" id="{item.ID}" style="display: none;">
Run Code Online (Sandbox Code Playgroud) javascript ×1