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   }); }); 

working fiddle

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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -