2
我想要一張初始爲黑色和白色的圖像,但是當我將它懸停在圖像上時,它會褪色到彩色圖像中。原型在鼠標懸停時會褪色爲黑白色
我發現如何用jQuery做到這一點,但是我對原型並不是很好,我也不知道如何將代碼轉換爲與Prototype庫一起工作。任何人都可以幫我嗎?
這裏是jQuery的功能:
<script type='text/javascript'>
$(document).ready(function(){
$("img.a").hover(
function() {
$(this).stop().animate({"opacity": "0"}, "slow");
},
function() {
$(this).stop().animate({"opacity": "1"}, "slow");
});
});
</script>
這裏是CSS:
<style>
div.fadehover { position: relative; }
img.a { position: absolute; left: 0; top: 0; z-index: 10; }
img.b { position: absolute; left: 0; top: 0; }
</style>
,這裏是人體代碼:
<div class="fadehover">
<img src="cbavota-bw.jpg" alt="" class="a" />
<img src="cbavota.jpg" alt="" class="b" />
</div>
感謝您抽出時間來幫助一個小夥子! :d