changing the bg color of an active click function in jquery?

Posted by pingpong on Stack Overflow See other posts from Stack Overflow or by pingpong
Published on 2010-12-22T05:51:58Z Indexed on 2010/12/22 5:53 UTC
Read the original article Hit count: 151

Filed under:
|
|

basically i have this click function in jquery: (this is just a snippet, not full)

$('.block').click(function(){

    var id= $(this).attr('id');

i want to chnage the background color of the block that has been clicked only, assigned with the id i.e.

$('.block').click(function(){

    var id= $(this).attr('id'); 

$('.block').css('background-color','grey');

but where do i assign the id, so jquery knows, to only turn the clicked block into grey, not the others, cheers

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html