Devdit
 

removeAttr jQuery คือคำสั่งอะไร ใช้ทำอะไร

1K

removeAttr jQuery คือคำสั่งลบ attribute ที่ต้องการจาก elements ที่กำหนด จากตัวอย่างสอนใช้คำสั่ง removeAttr ของ jQuery เพื่อลบ attribute style ของตัวอักษรสีแดงออกจาก id red สามารถเขียนโปรแกรมได้ดังนี้

 

ตัวอย่าง removeAttr jQuery คือคำสั่งอะไร ใช้ทำอะไร

<font id="red" style="color:red">RED</font>
<font id="green" style="color:green">GREEN</font>
<font id="blue" style="color:blue">BLUE</font>
<script>
    $("#red").removeAttr("style");
</script>

คำอธิบาย

removeAttr jQuery จากตัวอย่างเขียนโปรแกรม $("#red").removeAttr("style") หมายความว่าให้อ้างถึง id = red จากนั้นลบ attribute style ออกด้วยคำสั่ง removeAttr

แก้ไข 1 ปีที่แล้ว
ชอบ
ลิ้งก์
แชร์
Devdit มีช่อง YouTube แล้ว
เราสร้างวิดีโอเกี่ยวกับเทคโนโลยี ทำตามง่ายๆ