HTML:
<a id="link1" href="#">LINK1</a>
<div id="text1" style="display: none;">text1 div</div>
<a id="link2" href="#">LINK2</a>
<div id="text2" style="display: none;">text2 div</div>
<a id="link3" href="#">LINK3</a>
<div id="text3" style="display: none;">text3 div</div>
JS:
for (var i = 0; i <= 500; i++) {
$('#link' + i).click(function() {
$('#text' + i).toggle('fast');
return false;
});
}
但它不起作用。想法是让每个#link(number) 显示适当的#text(number) 块。但此时此刻我的 phpstorm 说“i”是可变变量....提前致谢