這可能聽起來很愚蠢,但我是一個Jquery noob,我試圖做一個div標籤來調整大小,當我在手機上左右滑動時,我不確定它爲什麼只執行一次?任何jquery大師在這裏可以幫助我!謝謝爲什麼我的jquery函數只能工作一次?
這裏是代碼
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
</head>
<body>
<div class="box">
</div>
<script>
$(function right(){
// Bind the swiperightHandler callback function to the swipe event on div.box
$("div.box").on("swiperight", swiperightHandler);
// Callback function references the event target and adds the 'swiperight' class to it
function swiperightHandler(event){
$(event.target).addClass("swiperight");
}
});
$(function left(){
// Bind the swiperightHandler callback function to the swipe event on div.box
$("div.box").on("swipeleft", swiperightHandler);
// Callback function references the event target and adds the 'swiperight' class to it
function swiperightHandler(event){
$(event.target).addClass("swipeleft");
}
});
</script>
</body>
</html>
thx傢伙!解決它我想我現在需要深入瞭解文檔來理解爲什麼:p –