6
2010
Binding Multiple Event Handlers
New feature ที่ 3 ใน jQuery 1.4 วิธีการกำหนด Event handlers ให้กับ Element ที่เราต้องการแบบรวดเดียวจบเลยครับ หรือแบบ Multiple event handlers โดยไม่ต้องมาเสียเวลามาเขียนให้มัน binding ทีละตัวครับ มาดู code กันเลยดีกว่า 1234567891011jQuery(’#foo).bind({ click: function() { // do something }, mouseover: function() { // do something }, mouseout: function() { // do something } }); จาก code ด้านบนเราจะเห็นได้ว่าเราสามารถที่จะ binding event [...]
14
2009
Events bind
มาทำความรู้จักกับ Event Bind กันบ้างครับ event bind นี้การทำงานของมันก็คือ การผูก event ต่างๆ เช่น blur, focus, load, resize, scroll, unload, beforeunload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error ให้เข้าไปอยู่กับ element หรือ tag ต่างๆเช่นถ้าเราต้องการจะให้ tag P ให้มี event click แล้วให้ alert ค่าอะไรสักอย่างออกมาโดยที่เราไม่ต้องไปไล่ใส่ code onClick ใน tag นั้นๆ สามารถทำได้โดยการใช้ Bind เนี่ยแหละครับ ตัวอย่าง 1234567<p>Click Here Test Event Bind</p> <script> $("p").bind("click",function(e){ alert("Bind onClick!!"); [...]
14
2009
Events ready
วันนี้มาทำความรู้จักกับ Events ที่ชื่อว่า ready กันครับ Function Ready นั้นทำงานเหมือนกับ window.onload มันพิเศษตรงที่เราสามารถจับ Function อื่นๆให้ผูกกับ onload ได้ function ready นี้จะทำงานเมื่อ DOM ทำงาน มาดูตัวอย่างกันเลยยิ่งอ่านจะยิ่งงงไปกันใหญ่ 1234567$(document).ready(function(){ alert(’DOM ready!!’); }); // Result : DOM ready!! เมื่อลองเอา code นี้ไปทดสอบดู จะเห็นได้ว่ามีการ alert ข้อความ DOM ready!! ออกมา เรามามารถนำ Function ไปใช้เมื่อต้องการให้โปรแกรมเราทำงานตั้งแต่การเปิด หรือ เรียก URL ขึ้นมาให้ทำงาน Javascript ที่ถูกผูกเข้ากับ Event นี้ก็จะเริ่มทำงานทันที
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



