我有一个添加div的jquery项目...我希望将这些div作为颜色选择器...所以我想使用websanova-wColorPicker jquery库..但是在将它与我的代码集成之后。我在chrome中遇到颜色选择器方法没有找到错误..
一旦我删除了我的jquery代码,添加div ...颜色选择器工作..我得出一个结论,因为我已经尝试了另一个颜色选择器库以及相同的错误的冲突.. .i也使用jquery ui
Uncaught TypeError: Object [object Object] has no method 'wColorPicker' i.html:83
jQuery.click.show i.html:83
f.event.dispatch jquery.1.7.1.min.js:3
f.event.add.h.handle.i jquery.1.7.1.min.js:3
所以这是我的问题..如何创建动态div与Websanova颜色选择器应用即。每个div都是一个颜色选择器。帮助。
代码:
<!DOCTYPE html>
<html>
<head>
<title>Websanova Color Picker</title>
<link href="css/index.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="./inc/jquery.1.7.1.min.js"></script>
<link rel="Stylesheet" type="text/css" href="./wColorPicker.css" />
<script type="text/javascript" src="./wColorPicker.js"></script>
</head>
<body>
<div id="wColorPicker7" class="hoverBox"></div>
<script type="text/javascript">
$("#wColorPicker7").wColorPicker({onSelect:function(color){/*do something*/}, mode: 'click', effect: 'fade', color: 'yellow'});
$(window).load(function(){
jQuery("#coldwn").click(function(event){
var showOptions = function()
{
$(this).css("background-image", "url(images/us.png)");
};
var showOptionso = function()
{
$(this).css("background-image", "url(images/ua.png)");
};
var cc = function()
{
var letters = '0123456789ABCDEF'.split('');
var c = '#';
for (var i = 0; i < 6; i++ ) {
c += letters[Math.round(Math.random() * 15)];
}
$(this).css("background-color", c );
};
w=document.getElementById('coldwn').offsetWidth;
var x = event.pageX;
var p=(x-403)*100/w;
var per=p.toFixed(0);
xa = document.getElementById('coldwn').offsetTop;
var x = event.pageX,
y = event.pageY;
var $mystub=jQuery("<div>").addClass("node").attr('id', x+'o').css({position: "absolute",left:x,top:xa,width:"16px",height:"20px"}).hover(showOptions,showOptionso);
var $mystuba=jQuery("<div>").addClass("color").attr('id', x+'i').css({position: "absolute",top:"7px",width:"16px",height : "14px",value:p,autocomplete:"off"}).click(cc);
$mystub.append($mystuba);
$('#coldwn').append($mystub);
$("#"+x+"i").wColorPicker({onSelect:function(color){/*do something*/}, mode: 'click', effect: 'fade', color: 'yellow'});
$("#"+x+"o").draggable({ containment: "#coldwn", scroll: false,axis: "x",
start: function() { },
drag: function(event, ui) {
var x = event.pageX;
var p=(x-403)*100/w;
var per=p.toFixed(0);
$('textarea').val(per);
// -webkit-linear-gradient(bottom, rgb(40,51,157) 32%, rgb(68,77,189) 66%, rgb(105,138,14) 77%);
},
stop: function() {
var x = event.pageX;
var p=(x-403)*100/w;
var per=p.toFixed(0);
alert(per);
} });
});
});
function d()
{
var i=20;
var str="";
alert($('#coldwn').children("div").size());
$('.node').children("div").each(function()
{
var kid = $(this);
var cr = $(this).css("background-color");
str+=cr+" "+i+"%,";
console.log(str);
i+=20;
console.log(kid.attr('id'),cr);
}).sort();
str+="rgb(105,138,14) 100%)";
alert(str);
$('#mainarea').css("background-image","-webkit-linear-gradient(bottom, "+str );
console.log("background-image","-webkit-linear-gradient(bottom, "+str);
// $('#mainarea').css("background-image","-webkit-linear-gradient(bottom, rgb(40,51,157) 32%, rgb(68,77,189) 66%, rgb(105,138,14) 77%)" );
}
</script>
<p>
<span id="u70">CSS GRADIENTS</span>
</p>
<p>
</p>
<div id="wrap">
<div id="topop" class="topop"></div>
<div id="mainarea" class="maingrad"></div>
<div id="coldwn" class="col"></div>
</div><br>
<div id="wColorPicker7" class="hoverBox"></div>
</body>
</html>
注意:jquery中的代码创建divs..i然后想要成为colorpickers
答案 0 :(得分:0)
得到它..jquery import override..each other ...确保没有重复