1 | $("#id") |
1 | $(".class") |
1 | $("element") |
1 | $("*") |
1 | $("selector1, selector2,.... selectorN") |
ตัวอย่างประกอบ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | < html > < head > < script type = "text/javascript" src = "path/to/jquery.js" ></ script > < script type = "text/javascript" > $("#mydi").show(); // เป็นการเลือก object ที่มี id ตามที่กำหนด $(".myclass").show(); // เป็นการเลือก object ที่มี class ตามที่กำหนด $("a").show(); // เป็นการเลือก object ที่มี tag ตามที่กำหนด คือ tag < a > $("*").show(); // เป็นการเลือก object ทั้งหมด $("a,p,span").show(); // เป็นการเลือก object แบบหลายๆ แท็ก ได้แก่ < a > < p > และ < span > </ script > </ head > < body > < p >www.ninenik.com</ p > < span >www.ninenik.com</ span > </ body > </ html > |