Jump to content

jquery changes css property


arunpatal

Recommended Posts

Hi,

 

The code below work fine when i want to change the value of background-color property

<script>
$(document).ready(function(){	 
	 $(".img_div").click(function(){
	 var element_value = $(this).val();
	$("#main_div").css({"background-color":element_value});
  });
});
</script>

But when i want to change property itself (background-color), its not working

<script>
$(document).ready(function(){	 
	 $(".img_div").click(function(){
	 var element_prop = $(this).val();
	$("#main_div").css({element_prop:"black"});
  });
});
</script>
Link to comment
https://forums.phpfreaks.com/topic/287514-jquery-changes-css-property/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.