這是我的網站:http://keironlowe.x10hosting.com/Javascript或jQuery的幫助
我需要知道如何上空盤旋時使紅線慢慢變長,慢慢地收縮回正常大小之後使用JavaScript或jQuery的。
有人能告訴我一些東西在正確的方向上開始嗎?
這是我的網站:http://keironlowe.x10hosting.com/Javascript或jQuery的幫助
我需要知道如何上空盤旋時使紅線慢慢變長,慢慢地收縮回正常大小之後使用JavaScript或jQuery的。
有人能告訴我一些東西在正確的方向上開始嗎?
您可以使用jQuery的animate做一些元素,其中包括定義應該多長時間動畫完成的持續時間參數。然後是需要一組函數的hover
函數。因此,這是一般的想法:
$('div', '#nav_container').hover(function() {
// this gets called on hover
$(this).animate({width: 'XXXpx'}, 10000); // 10000 = 10 seconds
}, function() {
// this gets called on mouseout
$(this).animate({width: 'XXXpx'}, 10000); // 10000 = 10 seconds
});
編輯:
至於你的評論,如果代碼是在<HEAD>
,你需要用的代碼document.ready
:
$(document).ready(function() {
// put the code you tried here
});
事情是這樣的:
$('#nav_container div').hover(
function(){$(this).find('img').animate({width:'100%'},{queue:false,duration:500});},
function(){$(this).find('img').animate({width:'auto'},{queue:false,duration:500});}
);
我似乎無法得到這個工作。 Ive得到
<腳本類型= 「文本/ JavaScript的」 SRC = 「的jquery.js」> <腳本類型= 「文本/ JavaScript的」> $( '的div', '#nav_container')。懸停(函數(){(this).animate({width:'230px'},10000); // },function(){ $(this).animate({width:'203px'},10000) ; }); – 2009-06-08 18:11:54