我有一個href按鈕,其上有一段JavaScript動畫,它使得籃子在懸停時上下跳動。但是,我需要將href鏈接更改爲輸入提交按鈕,我似乎無法讓動畫與輸入按鈕正常工作。Jquery Animate在輸入提交按鈕上工作?
這是我使用的動畫
<script type="text/javascript">
$(document).ready(function(){
$(".button").hover(function(){
$(":not(:animated)", this)
// first jump
.animate({top:"-=6px"}, 200).animate({top:"+=6px"}, 200)
// second jump
.animate({top:"-=3px"}, 100).animate({top:"+=3px"}, 100)
// the last jump
.animate({top:"-=2px"}, 100).animate({top:"+=2px"}, 100);
});
})
</script>
的JavaScript,這是HTML
<div class="addbasketbut">
<a class="button" href="#">
<img src="template_images/basketbutton.png" alt="" />Add to Basket
</a>
</div>
這是一部開拓創新的按鈕http://jsfiddle.net/tcherokee/wkfrG/
我的工作的jsfiddle不太經驗Jquery,所以任何幫助將不勝感激。
你好IanO,謝謝你的建議,但它不會工作。原因是該按鈕使用兩個圖像。一個背景圖像來設置按鈕本身的風格(不動畫)和另一個獲得動畫效果的圖像。我已經使用第一個背景圖像對輸入按鈕進行了樣式設置,但似乎無法使第二個圖像生成動畫。我嘗試將輸入按鈕封閉在div中並將圖像添加到div,但只是爲圖像和輸入按鈕設置了動畫。 – tcherokee
目前我可以通過這個jsfiddle http://jsfiddle.net/tcherokee/KYsCj/5/獲得兩個圖像的動畫。但我只是想讓籃子圖像變成動畫,而不是整個按鈕。 – tcherokee