jQuery event.dataคุณสมบัติ

❮ วิธีการจัดกิจกรรม jQuery

ตัวอย่าง

ส่งคืนข้อมูลที่ส่งผ่านด้วย on() วิธีการสำหรับแต่ละ <p> องค์ประกอบ:

$("p").each(function(i){
  $(this).on("click", {x:i}, function(event){
    alert("The " + $(this).index() + ". paragraph has data: " + event.data.x);
  });
});

ความหมายและการใช้งาน

คุณสมบัติ event.data มีข้อมูลทางเลือกที่ส่งผ่านไปยังวิธีเหตุการณ์เมื่อตัวจัดการการดำเนินการปัจจุบันถูกผูกไว้


ไวยากรณ์

event.data

Parameter Description
event Required. The event parameter comes from the event binding function

❮ วิธีการจัดกิจกรรม jQuery