ចំណងជើង
ចំណងជើង
នៅលើបន្ទាត់លេខ 12 នៃកម្មវិធីខាងលើ ការសរសេរថា $("#title").css({"font-size":"50px"}) គឺជាការប្រើប្រាស់ក្បួនខ្នាតក្នុងកញ្ចប់ jQuery ដើម្បីជ្រើសរើសយកធាតុ HTML មានអត្តសញ្ញាណជា title យកមកកែច្នៃ css របស់វា ដោយការដោះដូរទំហំនៃពុម្ពអក្សរនៅក្នុងធាតុនោះ អោយមានទំហំ 50px វិញ។
ដូចគ្នាដែរ យើងអាចធ្វើការជ្រើសរើសយកធាតុ HTML នានាតាមរយៈថ្នាក់របស់វា មកធ្វើការកែច្នៃផ្សេងៗ ដោយធ្វើដូចខាងក្រោមនេះ៖
កម្មវិធីជាភាសា JS
កម្មវិធីជាភាសា JS
More Examples of jQuery Selectors
Syntax | Description |
---|---|
$("*") | Selects all elements |
$(this) | Selects the current HTML element |
$("p.intro") | Selects all elements with class="intro" |
$("p:first") | Selects the first element |
$("ul li:first") | Selects the first |
$("ul li:first-child") | Selects the first |
$("[href]") | Selects all elements with an href attribute |
$("a[target='_blank']") | Selects all elements with a target attribute value equal to "_blank" |
$("a[target!='_blank']") | Selects all elements with a target attribute value NOT equal to "_blank" |
$(":button") | Selects all |
$("tr:even") | Selects all even |
$("tr:odd") | Selects all odd |