Aug
15
2009
15
2009
การใช้งาน Selector Filter แบบ last
การใช้งานของ Filter Last นั้นก็เหมือนๆกับ first เลยครับต่างกันตรงที่มันเอามาใช้ในการ select element สุดท้าย ครับ ตัวอย่างเช่นเรามี Table ที่มี TR จำนวน 3 Row ด้วยกัน เราจะทำการกำหนดสี background ให้กับ TR Row สุดท้ายในที่นี้ก็คือ Row 3 ให้มีสีเหลือง สามารถทำได้ดังนี้ครับ
1 2 3 | $(document).ready(function(){ $("tr:last").css({backgroundColor: 'yellow', fontWeight: 'bolder'}); }); |
ผลที่ได้ก็จะแสดงได้แบบนี้ครับ
| First Row |
| Middle Row |
| Last Row |
ลองเอาไปใช้กันดูครับ
Final Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | "http://www.w3.org/TR/html4/loose.dtd"> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"><!-- $(document).ready(function(){ $("tr:last").css({backgroundColor: 'yellow', fontWeight: 'bolder'}); }); // --></script> <table border="0"> <tbody> <tr> <td>First Row</td> </tr> <tr> <td>Middle Row</td> </tr> <tr> <td>Last Row</td> </tr> </tbody></table> |
Related Posts
Tags
.data
access iframe
advance
Ajax
attr
bind
browser
canvas
Core
debugs
Deferred
deferred.then
Deferred Object
delegate
DOM
Effect
event
Events
filters
google
HTML
html5
iframe
Image
jquery
jquery.data
jQuery 1.4
jquery 1.5
jQuery 1.6
jQuery 1.7
jquery mobile
jquery plugin
jquery ui
json
live
Plugin
plugins
selector
Selectors
show()
UI
undelegate
validate
welcome
what's jquery
Facebook Development
Google+ Page
Categories
- HTML5 & CSS3 (8)
- jQuery 1.4 (9)
- jQuery 1.5 (6)
- .data (1)
- jQuery 1.6 (3)
- .data (1)
- jQuery 1.7 (4)
- Events (1)
- jQuery Mobile (3)
- jQuery UI (3)
- Mobile (1)
- News (8)
- Others (28)
- Plugin (15)
- The basics of jQuery (9)
- Tips (13)
- คู่มือการใช้งาน jQuery ฉบับ ภาษา ไทย (30)
- Ajax (4)
- Attributes (1)
- Core (1)
- Deferred (3)
- Effects (7)
- Events (3)
- Manipulation (2)
- Selectors (5)
- Traversing (2)
- Utilities (2)

An article by







