<script type="text/javascript">
$(document).ready(function () {
var kv_num = 0;
function nextKv() {
alert("下一个");
$(".control").attr("style", "pointer-events:none");
kv_num++;
if (kv_num == 4) { kv_num = 0; }
$(".kv_pic").animate({ left: -1000 * kv_num }, { easing: 'easeInOutQuad', duration: 500, complete: function () {
$(".control").attr("style", "pointer-events:auto");
}
});
$(".kv_word>ul").stop().animate({ left: -340 * kv_num }, { easing: 'easeInOutQuad', duration: 800, complete: function () { } });
$(".kv_dot ul li").removeClass("action").eq(kv_num).addClass("action");
}
function prevKv() {
alert("上一个");
$(".control").attr("style", "pointer-events:none");
kv_num--;
if (kv_num == -1) { kv_num = 3; }
$(".kv_pic").animate({ left: -1000 * kv_num }, { easing: 'easeInOutQuad', duration: 500, complete: function () {
$(".control").attr("style", "pointer-events:auto");
}
});
$(".kv_word>ul").stop().animate({ left: -340 * kv_num }, { easing: 'easeInOutQuad', duration: 800, complete: function () { } });
}
});
$("#kv").append("</div><div class='control'><div class='prev'><img src='../../image/icons_move_left.jpg' onclick='prevKv();'/></div><div class='next'><img id='nextKv' src='../../image/icons_move_right.jpg' onclick='nextKv();'/></div></div>");
</script>
//onclick拿掉 $("#kv").append("</div><div class='control'><div class='prev'><img src='../../image/icons_move_left.jpg' /></div><div class='next'><img id='nextKv' src='../../image/icons_move_right.jpg' /></div></div>"); //$(document).ready加上這兩個 $(document).on('click', '.prev', function () { prevKv(); }) $(document).on('click', '.next', function () { nextKv(); })
試試
非常完美解决啦,感谢大神的专业回答!谢谢!