jQuery removeAttr()เมธอด

❮ วิธีการ jQuery HTML/CSS

ตัวอย่าง

ลบแอตทริบิวต์สไตล์ออกจากทุก <p> องค์ประกอบ:

$("button").click(function(){
  $("p").removeAttr("style");
});

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

removeAttr() วิธีการลบแอตทริบิวต์อย่างน้อยหนึ่งรายการออกจากองค์ประกอบที่เลือก


ไวยากรณ์

$(selector).removeAttr(attribute)

Parameter Description
attribute Required. Specifies one or more attributes to remove. To remove several attributes, separate the attribute names with a space

ลองด้วยตัวคุณเอง - ตัวอย่าง


วิธีลบแอตทริบิวต์ id และคลาสออกจากองค์ประกอบที่เลือก


❮ วิธีการ jQuery HTML/CSS