我需要你的幫助,我的代碼有問題,當從jQuery的 插入新的div插入DIV並不適用於我的jQuery代碼,如果任何人有解決辦法,請告訴我 這我的HTML代碼如何在插入表單jQuery代碼的div上運行我的jquery代碼?
<input type="text" id="t" value=""/>
<a href="#" class="btn">click</a><br/>
<br/>
<div class="profileInfoSectionwall"style="border:1px solid #ccc">
text111111
<div class="remove" style="display: none;">
<a class="post_remove" rel="1" herf="#">X</a>
</div>
</div>
<br/>
<div class="profileInfoSectionwall"style="border:1px solid #ccc">
text222222
<div class="remove" style="display: none;">
<a class="post_remove" rel="2" herf="#">X</a>
</div>
</div>
和這個jQuery代碼
$(document).ready(function(){
$(".profileInfoSectionwall").mouseenter(function(){
$(this).children(".remove").show();
});
$(".profileInfoSectionwall").mouseleave(function(){
$(".remove").hide();
});
$(".btn").click(function(){
var s=$("#t").attr("value");
$(this).after("<br/><br/><div class='profileInfoSectionwall' style='border:1px solid #ccc'>"+s+"<div class='remove' style='display: none;'><a class='post_remove' rel='3' herf='#'>X</a></div></div>");
return false;
})
})
在此先感謝
從jQuery 1.7開始,不推薦使用.live()方法。使用.on()附加事件處理程序。老版本的jQuery用戶應優先使用.delegate(),而不要使用.live()。 http://api.jquery.com/live/ – arunes 2012-03-01 12:29:41
@Mona Abdelmajeed感謝這個解決方案與我一起工作,非常感謝 – 2012-03-01 12:31:23