jquery color pick on index.html
我尝试在我的应用程序中添加jquery插件,但不起作用:| 因此,在我的头脑中:jquery color pick on index.html,jquery,css,Jquery,Css,我尝试在我的应用程序中添加jquery插件,但不起作用:| 因此,在我的头脑中: <link rel="stylesheet" media="screen" type="text/css" href="./style/colorpicker.css" /> <script type="text/javascript" src="./scripts/jqueryColorPicker/colorpicker.js"></script> 在身体的某个地方:
<link rel="stylesheet" media="screen" type="text/css" href="./style/colorpicker.css" />
<script type="text/javascript" src="./scripts/jqueryColorPicker/colorpicker.js"></script>
在身体的某个地方:
<script>
$("./images/colorwheel.png").ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
$('#footer').css('backgroundColor', '#' + hex);
$('#header').css('backgroundColor', '#' + hex);
}
});
</script>
$(“/images/colorwheel.png”).ColorPicker({
颜色:“#0000ff”,
onShow:函数(colpkr){
美元(colpkr).fadeIn(500);
返回false;
},
onHide:function(colpkr){
$(colpkr).淡出(500);
返回false;
},
onChange:函数(hsb、十六进制、rgb){
$('#footer').css('backgroundColor','#'+hex);
$('#header').css('backgroundColor','#'+hex);
}
});
但那个轮子没有出现在我的页面上:|我是jquery的新手…:(添加一个可容纳颜色选择器的元素:
<input type="text" id="colorPicker">
您还应该使用ready
确保在执行js时加载元素:
$(document).ready(function() {
//Your code
});
如果页面上有多个颜色选择器,则必须使用类而不是id。颜色选择器$(“/”/images/colorwheel.png”)的选择器错误 您需要有一个html元素,颜色选择器应该在该元素上工作 你可以吃类似的东西
<div class="someClass"><div>
1.您没有在
中包含jquery
库
2.选择器错误,例如,如果要将颜色选择器附加到textbox#colorpicker,则代码应为:
<input type="text" id="colorpicker">
$("#colorPicker").ColorPicker({ ... });
你的选择器
$(“/images/colorwheel.png”)
错了…我应该放什么呢??:|只要把你的javascript代码放在我写的//你的代码
的地方就行了。如果没有就绪,问题是当你调用ColorPicker
时,元素可能无法加载。
$(".someClass").ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
$('#footer').css('backgroundColor', '#' + hex);
$('#header').css('backgroundColor', '#' + hex);
}
});
<input type="text" id="colorpicker">
$("#colorPicker").ColorPicker({ ... });
$(document).ready(function() {
$("#colorPicker").ColorPicker({ ... });
});