我写了这段代码,我需要用 jquery 处理点击事件,但它在任何浏览器中都不起作用,当我点击任何元素时,什么都没有发生。div 在 css 中没有 z-index;
洞“新闻”元素动态添加 这是html代码
<div class="news">
<div class="meta-inform">
<div id="waiting">not accepted</div>
<div id="accpted">accepted</div>
<div class="edit">
<div class="editedBy" id="editedBy" >
<div id="editLabel" style="display:inline">edited by</div>
<div id="editorName" style="display:inline">arvin</div>
</div>
<div id="editTime" class="editTime">
<div id="editDate" style="display:inline" >چdate</div>
<div id="editDate" style="display:inline">time</div>
</div>
</div>
</div>
<div id="littleNews">
<div id="number">1000</div>
<div id="divider1"></div>
<div id="title">title</div>
<div id="divider2"></div>
<div id="littleNewsTime">time</div>
<div id="littleNewsDate">date</div>
<div id="divider3"></div>
<div id="category">cat</div>
<div id="part">part</div>
<div id="segment">sgmnt</div>
<div id="divider4"></div>
<div id="writer">writer</div>
<div id="view">view post</div>
</div>
<div class="functions">
<div id="edit">edit</div>
<div id="delete">delete</div>
<div id="accptThis">accept</div>
</div>
</div>
这是我的jQuery代码
$(document).ready(function () {
$("#littleNews").click(function () {
alert("hi");
});
});
它不适用于“新闻”类中的任何元素
我有这段代码,这段代码创建了整个 div
$("#news").clone().appendTo("#mainDiv").attr("id","news"+(i+1))