$("selector").css("value");
<html> <head> <title>ThaiCreate.Com jQuery Tutorials</title> <script type="text/javascript" src="jquery-1.6.4.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("body").css("background-color","yellow"); $("p").css("background-color",$("#div1").css("background-color")); $("#btn1").click(function(){ $("body").css("background-color","pink"); $("#div1").css("background-color","green") $("#div2").append($("body").css("background-color")) $("#div3").css({"font-size:":"10px","color":"gray","padding":"5px 0px 5px 10px"}); $("#txt1").height("30px"); $("#txt1").width("100px"); }); }); </script> </head> <body> <p><b>Welcome to... </b></p> <div id="div1" style="background:red">Welcome to ...</div> <div id="div2">Body Background-color ...</div> <div id="div3">2011 ...</div> <input type="text" id="txt1"> <input type="button" id="btn1" value="Click"> </body> </html>
<html> <head> <title>ThaiCreate.Com jQuery Tutorials</title> <style type="text/css"> .css1 { font-size: 11px; font-weight: bold; color: #000000; } .css2 { font-size: 20; font-weight: bold; color: #FF0000; } </style> <script type="text/javascript" src="jquery-1.6.4.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#btnRemoveCss").click(function(){ $(".css2").removeClass(); }); $("#btnAddCss").click(function(){ $(".css1").addClass("css2"); }); }); </script> </head> <body> <p class="css1"> Welcome to jQuery on ThaiCreate.Com Tutorials</p> <p class="css2"> Version 2011</p> <input id="btnRemoveCss" type="button" value="Remove Css"> <input id="btnAddCss" type="button" value="Add Css"> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท