Php ajax成功后jquery.css函数不起作用
我有这个css,它使div不可读取Php ajax成功后jquery.css函数不起作用,php,html,jquery,css,ajax,Php,Html,Jquery,Css,Ajax,我有这个css,它使div不可读取 .commentpost{ pointer-events: none; } 使用此html <div class="commentsDiv"> //some code to show the comments from db // <div class="w-100"> <div class="div-bottom-3 d-flex " style=
.commentpost{
pointer-events: none;
}
使用此html
<div class="commentsDiv">
//some code to show the comments from db
//
<div class="w-100">
<div class="div-bottom-3 d-flex " style="position: absolute;">
<div class="form__group">
<input type="text" class="form__input comment" id="comment"
placeholder="Add a comment" name="comment"/>
</div>
<div class="pt-1 commentpost">
Post
</div>
</div>
</div>
</div>
ajax成功后,它将注释保存在db中,并在另一个div中显示,但我无法再次按post div,指针事件保持为none我有个主意
试着这样做
$(document).on('click','.commentpost',function(e){
//ajax call happens
//and on success reload div commentsDiv with .load()
})
使用文档了解是否存在可单击元素,因为我认为您已经更改了可单击的div
它工作得很好,因为如果元素是通过ajax jquery动态创建的,那么您就会明白这些新div并不存在于document ready上,而只存在于原始div上,因此,每次单击文档时都会查看文档中当前存在的内容,并在div更改时防止事件冒泡谢谢dude,这+将可单击的div放置在加载的div之外使其正常工作。当我写入时,没有问题。单击时,我总是按照上面描述的方式写入,我想不出不这样做的理由,特别是如果您曾经在不同的时间在一个div上发生过多件事情,或者如果元素是由jquery创建的,那么最好使用上面相同的设置。
$(document).on('click','.commentpost',function(e){
//ajax call happens
//and on success reload div commentsDiv with .load()
})