14
2010
ถึงคราวของ jQuery .delegate() กันบ้างครับ
วันนี้มาทำความรู้จักกับ Method Deledate กันบ้างครับซึ่ง Method หรือ Function นี้จะมีอยู่ใน jQuery 1.4 นะครับ ตามคำจำกัดความที่ทาง jQuery นั้นเขียนไว้ว่า “Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements.” แปลเป็นไทยได้ทำนองนี้ครับ (แปลได้ งูๆปลาๆนะครับ – -’ ) jQuery delegate ก็คือ Function หรือ method ที่ใช้ในการ แทรก Event ต่างๆเข้าไปสามารถแทรกเข้ามาได้มากกว่า 1 event เช่น event Click, hover, mouseover, mouseout เป็นต้น ซึ่งจะแทรกเข้าไปในทุกๆ elements ที่ตรงกับที่เราได้ selector เอาไว้
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
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


