I need your help in my code I have problem when new div inserted from jquery the inserted div does not apply to my jquery code if anyone have solution please tell me and this my Html code
<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>
and this jquery code
$(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;
})
})
thanks in advance
You may want to try using the .on method so something like:
$(".profileInfoSectionwall").on('mouseenter', function(){
$(this).children(".remove").show();
});
$(".profileInfoSectionwall").on('mouseleave', function(){
$(".remove").hide();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With