试试这个:
$(document).ready(function() {
$('label').hover(function() {
var hue = 'rgb('
+ (Math.floor(Math.random() * 256)) + ','
+ (Math.floor(Math.random() * 256)) + ','
+ (Math.floor(Math.random() * 256)) + ')';
$(this).stop().animate({ color: hue }, 500);
},function() {
$(this).stop().animate({ color: '#000' }, 500);
});
});
也看到我jsfiddle。
=== UPDATE ===
function startAnimation(o) {
var hue = 'rgb('
+ (Math.floor(Math.random() * 256)) + ','
+ (Math.floor(Math.random() * 256)) + ','
+ (Math.floor(Math.random() * 256)) + ')';
$(o.currentTarget).animate({ color: hue }, 500, function() {
startAnimation(o);
});
}
$(document).ready(function() {
$('label').hover(
startAnimation,
function() {
$(this).stop().animate({ color: '#000' }, 500);
}
);
});
看到我更新jsfiddle。
请张贴您的HTML和CSS。这里没有足够的代码来知道发生了什么问题。 – maxedison
你需要什么?除了身体上的东西外,没有任何CSS。而html只是一堆输入标签。 – yoshi