<strong class="comment" id="comment[6]">Show comments</strong>
<div id="comments[6]">HERE GO COMMENTS</div>
还有我的 JS 文件:
$(document).ready(
function() {
$(".comment").click(
function() {
var id = $(this).attr("id").replace("comment", "comments");
//document.getElementById(id).style.display = 'none';
$('#' + id).hide();
} );
});
HTML代码是用PHP生成的,所以有很多数字div,每次点击显示/隐藏对应的div。但问题是,就 Javascript 而言(注释行)一切正常,但是当我尝试使用 jQuery 时没有任何反应。问题出在哪里?