Creat plugin with jQuery, select just this ?!
Hi all !
I want creat a jQuery plugin for colorPicker, so I have write this function :
-
$.fn.colorPicker = function(options)
{
// Options
options = arrayMerge(
{
colorDefault : "#DDDDDD"
},options);
This = this;
init();
This.click(function(){
setColor('#000000");
});
function init()
{
if(!getColor())
setColor(options.colorDefault);
else
setColor(getColor());
}
function setColor(color)
{
This.val(color);
This.css('background-color', color);
}
function getColor()
{
return This.val();
}
// function arrayMerge(){ [...] }
This is the JS :
-
$(document).ready(function()
{
$('.colorPicker').colorPicker({
colorDefault : '#444444'
});
});
And the HTML :
-
<form action="nanani" method="post"/>
<input type="text" class="colorPicker" value="#DDDD33"/>
<input type="text" class="colorPicker"/>
<input type="text" class="colorPicker"/>
<input type="text" class="colorPicker"/>
</form>
Now... When I set a color for just one colorPicker [This.click()], this code change for all 'colorPicker' class who are initiate with the JavaScript...
How can I do for select just this ??
[Sorry for my english ^^ I'm french :p]
Thank you all for help !