这是我的网站: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