0
我试图做的事:jQuery的滑块的颜色选择器/滑块以更改背景
降低滑块的温度值,我需要圆圈代表明星逐渐增加,改变背景颜色为这个链接:http://astro.unl.edu/naap/hr/animations/hrExplorer.html
但我的代码是没有这样做.....请参阅从$线( “#s_tem”)滑块({ 见我的代码:http://jsfiddle.net/NxNXJ/19/
谢谢..
我试图做的事:jQuery的滑块的颜色选择器/滑块以更改背景
降低滑块的温度值,我需要圆圈代表明星逐渐增加,改变背景颜色为这个链接:http://astro.unl.edu/naap/hr/animations/hrExplorer.html
但我的代码是没有这样做.....请参阅从$线( “#s_tem”)滑块({ 见我的代码:http://jsfiddle.net/NxNXJ/19/
谢谢..
你是分配变量ch osenColor值如下:#597459745974
哪些是无效的CSS颜色属性。
[编辑]下面是一些代码,应该让你去:
$("#s_tem").slider({
change: function(event, ui)
{
var hexValue = ui.value.toString(16).toUpperCase();
if (hexValue.length < 2) hexValue = "0" + hexValue;
var chosenColor = NumberToHexColor(hexValue);
$('#t_tem').val(chosenColor);
$("#star").css('background-color', chosenColor);
},
value: 5800,
min: 2300,
max: 40000,
step: 100,
});
function NumberToHexColor(Number)
{
var HexColor = '' + Number;
while (HexColor.length < 6)
{
HexColor = '0' + HexColor;
}
return '#'+ HexColor;
}
但我怎么解决这个问题? 我无法找到我如何分配这些值。 – David 2012-01-27 17:28:05
我编辑/添加到我的答案。 – 2012-01-28 19:19:50
我做了你向我展示的内容,是正确的。但是在操作幻灯片温度时,它应该随着星星的增加或减少而改变颜色。如果增加颜色的圆应该变成橙色。像这里:http://astro.unl.edu/naap/hr/animations/hrExplorer.html – David 2012-01-30 11:37:21