santa
santa

Reputation: 12512

Pick background color on click

If I have a div with an inline style specifying background color, how do I get the color value on click w/ jQuery?

$(".myDiv").click(function(){
   var myColor = $(this)....
});

<div class="myDiv" style="background-color:#8080C0"></div>

Upvotes: 0

Views: 74

Answers (1)

zerkms
zerkms

Reputation: 254944

$(this).css('background-color')

http://jsfiddle.net/zerkms/eWWXT/

Upvotes: 2

Related Questions