我的jQuery代码有问题。
我显示隐藏的div
,当鼠标悬停此div
的兄弟时,会显示。
但是当调用我的AJAX函数时,jQuery不起作用。
<div class="parent">
<div class="theDiv" style="display:none">
</div>
<div class="sibling">
</div>
</div>
$('.sibling').hover(function(){
$(this).parent().find('.theDiv').fadeIn('fast');
});
$('.catFilterSelect').change(function(){
$.ajax({
url:"load_data.php",
method:"POST",
data:{
reg:a,
price:b,
type:c,
subject:d,
city:e,
typeSubject:typeSubject
},
dataType:"text",
success:function(data){
$('.catPostsBox .catPost').remove();
$('.catPostsBox').append(data);
}
});
})
此脚本在AJAX之前有效,但在此之后无法正常工作
答案 0 :(得分:0)
<div class="parent">
<div class="theDiv" style="display:none">
</div>
<div class="sibling">
</div>
</div>
<script>
$(function(){
$('.sibling').hover(function(){
$(this).parent().find('.theDiv').fadeIn('fast');
});
});
or -- both are same
$(document.ready(function(){
$('.sibling').hover(function(){
$(this).parent().find('.theDiv').fadeIn('fast');
});
});
</script>
<script>
$(function(){
$('.catFilterSelect').change(function(){
$.ajax({
url:"load_data.php",
method:"POST",
data:{
reg:a,
price:b,
type:c,
subject:d,
city:e,
typeSubject:typeSubject
},
dataType:"text",
success:function(data){
$('.catPostsBox .catPost').remove();
$('.catPostsBox').append(data);
}
});
})
)};
</script>