动态创建一个元素下具有类“父” 和应用一些CSS类的元素,即“子” 现在我想申请一些“id” ,所以我想知道如何做到这一点如何在以下代码中应用“id”代码
$(".parent").append("<a class='child' href='#bookmark" + cAnchorCount++ + "'> "+ $(this).text() +"</a>");
,以及如何在事件的一些事件绑定到它像鼠标将其
我试过,但没有工作
$(".pushLinkBtnContainer").append("<a id='$(this).text()' class='pushLinkBtn' href='#bookmark" + cAnchorCount++ + "'>".bind("mouseover", function() {
$(this).css("background-color", "red");
}) + "</a>");
你想要做什么目前还不清楚。 –
为什么你想要一个ID?你试图给锚元素添加一个id –
好吧让我编辑我的问题 – Faizan