jQuery Change CSS Dynamically


/ Published in: JavaScript
Save to your folder(s)

Read more here: http://www.jquery4u.com/dynamic-css-2/change-css-jquery/


Copy this code and paste it in your HTML
  1. $('jQuery selector').css({"css property name":"css property value"
  2.  
  3. //change paragraph text colour to green
  4. $('p').css({"color":"green"});
  5.  
  6. //float all divs with class .left
  7. $('div.left').css('float');
  8.  
  9. //change all elements with class .bg-red to have a red background
  10. $('.bg-red').css({"background-color":"red"
  11.  
  12. newimg.css('background-image': 'url('+newimgsrc+')');
  13. newimg.css('position': 'absolute');
  14. newimg.css('height': '70px');
  15. newimg.css('width': '200px');
  16. newimg.css('top': '68px');
  17. newimg.css('right': '2px'

URL: http://www.jquery4u.com/dynamic-css-2/change-css-jquery/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.