jQuery check element ID -
i know there plugin called .hasclass();
i have following
$('#page_background, #header_background').colorpicker({...
how check if page_background clicked , not header_background?
this have now, won't work.
$('#page_background, #header_background').colorpicker({ onsubmit: function(hsb, hex, rgb, el) { $(el).val(hex); $(el).colorpickerhide(); var id = this.id; if(id == 'page_background') $('body').css("background-color","#"+hex); }, onbeforeshow: function () { $(this).colorpickersetcolor(this.value); } }) .bind('keyup', function(){ $(this).colorpickersetcolor(this.value); });
$(function(){ $('#page_background, #header_background').click(function(){ var id = this.id; if(id == 'page_background') // page background else //header }); }); as using inside colorpicker onsubmit function
onsubmit: function(hsb, hex, rgb, el) { where element el, id use
var id = $(el).attr('id'); // or var id = $(el).prop('id'); // new way //or var id = el.id; // should work
Comments
Post a Comment