I have a div
I want when user clicks on this div the background color of div should be display in alert box using jquery only ?
Try this
<script type="text/javascript">
$(document).ready(function(){
$("div").click(function(){
var $c=$(this).css("background-color");
alert($c);
});
});
</script>
$('div').click(function() {
alert($(this).css('background-color'));
});
jsFiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With