$(selector).action()
<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(){ $("#btnClick").click(function(){ $(this).val("Hello"); }); }); </script> </head> <body> <input type="button" id="btnClick" value="Click"> </body> </html>
<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(){ $("#btnText").click(function(){ $("#txt1").val($("#btnText").val()); }); $("#btnClear").click(function(){ $("#txt1").val(''); }); }); </script> </head> <body> <input type="text" id="txt1"> <input type="button" id="btnText" value="input text = 123 "> <input type="button" id="btnClear" value="Clear"> </body> </html>
<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(){ $("#btnHide").click(function(){ $("p").hide(); $("div").hide(); }); $("#btnShow").click(function(){ $("p").show(); $("div").show(); }); }); </script> </head> <body> <p>string paragraph string paragraph string paragraph</p> <div>string div string div string div</div> <input type="button" id="btnHide" value="Hide"> <input type="button" id="btnShow" value="Show"> </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>
$("p#p1")
<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(){ $("#btnHide").click(function(){ $("p#p1").hide(); }); $("#btnShow").click(function(){ $("p#p1").show(); }); }); </script> </head> <body> <p id="p1">string paragraph string paragraph string paragraph</p> <p>string div string div string div</p> <input type="button" id="btnHide" value="Hide"> <input type="button" id="btnShow" value="Show"> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท