我在下面有以下脚本。我从php(JSON编码)获取数据。当我悬停鼠标时,我试图改变块的颜色,但它不起作用。任何的想法 ?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(e) {
//
$(".comment-block").mouseenter(function(){
$(".comment-block").css("background-color", "yellow");
});
$(".comment-block").mouseout(function(){
$(".comment-block").css("background-color", "lightgray");
});
//Show Initial Data
$.ajax({
type: "get",
url:"main_board.php",
cache: false,
data: { get_param : "value" },
dataType:"json",
success:function(data) {
$.each(data, function(index, element) {
var final_data = "<div class='comment-block'>" + "<div class ='comment-item'>" + "<div class ='comment-avatar'>" + "<img src='avtar.png' alt= 'avatar'></div>" + "<div class='comment-post'>" +"<h3>" + element.UserName + "<span></h3><p>" + element.Messages + "</p></div></div>";
$("#php").append($(final_data).hide().fadeIn());
});
}
});
});
</script>