jQuery Misc removeData()เมธอด

❮ วิธี jQuery เบ็ดเตล็ด

ตัวอย่าง

ลบข้อมูลที่แนบก่อนหน้านี้ออกจาก <div> องค์ประกอบ:

$("#btn2").click(function(){
  $("div").removeData("greeting");
  alert("Greeting is: " + $("div").data("greeting"));
});

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

เมธอด removeData() จะลบข้อมูลที่ตั้งค่าไว้ก่อนหน้านี้ด้วยเมธอดdata()


ไวยากรณ์

$(selector).removeData(name)

Parameter Description
name Optional. Specifies the name of data to remove.
If no name is specified, this method will remove all stored data from the selected elements

❮ วิธี jQuery เบ็ดเตล็ด