どちらも私には正しく機能していないようです。クエリから開始:
<script>
$(function() {
$("#button1").hover(function() {
$("#button1").animate({opacity: 0.5}, 500);
});
});
</script>
これにより、不透明度が下にシフトしますが、マウスリーブで再開しません。Jquerysホバーページは、次のように入出力アクションを実行するように指示します。
.hover(handlerIn(eventObject)、handlerOut(eventObject))
したがって、これを行うと、マウスインとマウスアウトの両方のアニメーションが表示されます。
<script>
$(function() {
$("#button1").hover(function() {
$("#button1").animate({opacity: 0.5}, 500),
$("#button1").animate({opacity: 1}, 500);
});
});
</script>
だから私はそれをあきらめて、mouseenter /mouseleaveコンボを試しました:
<script>
$(function() {
$("#button1").mouseenter(function() {
$("#button1").animate({opacity: 0.5}, 500);
});
("#button1").mouseleave(function() {
$("#button1").animate({opacity: 1}, 500);
});
});
</script>
それは単にmouseenterアニメーションに固執します。だから私はcssメソッドを試しました:
<style>
a:hover {
opacity: 0.5;
}
</style>
<div>
<a id="button1" ><img src="Assets/button.png"></a>
</div>
ジャックしません。:肩をすくめる: