1
2010
jQuery 1.4 : Passing Attributes to jQuery
เอาละวันนี้เริ่มต้นด้วย Features แรกกันเลยละกันครับ จากทั้งหมด 15 features ใน jQuery 1.4 แต่ก่อนนั้นเวลาที่เราจะเปลี่ยนแปลงค่า Attributes ด้วย jQuery นั้นเราจะใช้ function attr ในการเปลี่ยนแปลงค่าหรือเพิ่มเข้าไปใหม่ เช่น 1 $("input").attr( "value", "Hello World!!!" ); หรือถ้าเราจะเปลี่ยน Link ใน Tag A แต่ก่อนเราก็เขียนแบบนี้ครับ 1 $("a").attr("href","http://www.jquery.com"); แต่ในความสามารถใหม่ของเวอร์ชั่น 1.4 นี้เราสามารถที่จะเพิ่ม Attributes เข้าไปได้ทีเดียว รวมไปถึงสามารถกำหนด Event ไปด้วยเลยก็ได้ ลองดูจากตัวอย่าง code ด้านล่างนี้จะเข้าใจง่ายกว่าครับ ตัวอย่างนี้เป็นการกำหนดค่าให้กับ Tag a 1234567jQuery(’<a />’, { id: ‘foo’, href: ‘http://google.com’, title: ‘Become a Googler’, rel: ‘external’, text: ‘Go to Google!’ });
Tags
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


