Pages

Saturday, June 15, 2013

How to modify an HTML object's CSS property dynamically by using JQyery?

If user want to change the CSS property of an HTML Objects on the fly, you can use JQuery,
For example, if you want to change the color of all the text in a <DIV> element,

HTML
 <div id="change">Make Me in Red Color</div>
 <button id="color">Change Color</button>

JQuery

$(document).ready(
 function() {
  $("#color").click(
   function() {
    $("#change").css("color", "red");
   });
 });

DEMO

No comments:

Post a Comment