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
Categories
- jQuery 1.4 (8)
- jQuery Mobile (2)
- jQuery UI (2)
- News (2)
- Others (23)
- Plugin (11)
- The basics of jQuery (5)
- Tips (12)
- คู่มือการใช้งาน jQuery ฉบับ ภาษา ไทย (25)
- Ajax (4)
- Attributes (1)
- Core (1)
- Effects (7)
- Events (3)
- Manipulation (2)
- Selectors (4)
- Traversing (2)
- Utilities (1)

An article by



