jquery随机颜色悬停
我使用 jquery color 生成一些随机颜色。我希望当用户将鼠标悬停在任何单选按钮标签上时显示这些颜色。
按照此网站上的示例,我想我可以尝试:
spectrum();
function spectrum(){
var hue = ('lots of stuff here that generates random hue -- code on example webpage')
$('label').hover(function() {
$(this).animate( { color: hue }, 10000) });
spectrum();
}
我的悬停选择器不起作用,所有内容都保持默认颜色。我显然以某种方式搞砸了,但我没有足够的经验来理解出了什么问题。有什么建议吗?
I'm using jquery color to generate some random colors. Id like these colors to appear when the user hovers over any radio button labels.
Following the example on this site, i thought i might try:
spectrum();
function spectrum(){
var hue = ('lots of stuff here that generates random hue -- code on example webpage')
$('label').hover(function() {
$(this).animate( { color: hue }, 10000) });
spectrum();
}
My hover selector isn't working and everything is staying its default color. I'm obviously bungling this somehow, but I'm not experienced enough to understand what's going wrong. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
另请参阅我的 jsfiddle。
=== 更新 ===
请参阅我更新的 jsfiddle。
Try this:
Also see my jsfiddle.
=== UPDATE ===
See my updated jsfiddle.
$('label').hover
将为标签添加 mouseover/mouseout 事件。你无限地这样做,因为你一遍又一遍地调用频谱。试试这个吧。
$('label').hover
will add a mouseover/mouseout event to the label. You are doing this infinitely as, you are calling spectrum over and over again.Try this instead.
主要问题是jQuery不支持彩色动画。可以找到更多结果 jQuery:输入字段的动画文本颜色?
The main problem that jQuery doesn't support the color animation. More results can be found jQuery: animate text color for input field?