ล่าสุดการพัฒนาเว็บบทเรียน
×

JavaScript การอ้างอิง

ภาพรวม

JavaScript

JS เชือก JS จำนวน JS ผู้ประกอบการ JS งบ JS คณิตศาสตร์ JS วันที่ JS แถว JS บูลีน JS นิพจน์ทั่วไป JS สถานการณ์โดยรวม JS การแปลง

เบราว์เซอร์ BOM

Window Navigator Screen History Location

HTML DOM

DOM เอกสาร DOM องค์ประกอบ DOM แอตทริบิวต์ DOM เหตุการณ์ DOM รูปแบบ

HTML วัตถุ

<a> <abbr> <address> <area> <article> <aside> <audio> <b> <base> <bdo> <blockquote> <body> <br> <button> <canvas> <caption> <cite> <code> <col> <colgroup> <datalist> <dd> <del> <details> <dfn> <dialog> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <footer> <form> <head> <header> <h1> - <h6> <hr> <html> <i> <iframe> <img> <ins> <input> button <input> checkbox <input> color <input> date <input> datetime <input> datetime-local <input> email <input> file <input> hidden <input> image <input> month <input> number <input> password <input> radio <input> range <input> reset <input> search <input> submit <input> text <input> time <input> url <input> week <kbd> <keygen> <label> <legend> <li> <link> <map> <mark> <menu> <menuitem> <meta> <meter> <nav> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <s> <samp> <script> <section> <select> <small> <source> <span> <strong> <style> <sub> <summary> <sup> <table> <td> <th> <tr> <textarea> <time> <title> <track> <u> <ul> <var> <video>

วัตถุอื่น ๆ

CSSStyleDeclaration


 

HTML DOM removeAttributeNode() Method

<ธาตุวัตถุ

ตัวอย่าง

นำ class โหนดแอตทริบิวต์จาก <h1> องค์ประกอบ:

var elmnt = document.getElementsByTagName("H1")[0];  // Get the first <h1> element in the document
var attr = elmnt.getAttributeNode("class");          // Get the class attribute node from <h1>
elmnt.removeAttributeNode(attr);                     // Remove the class attribute node from <h1>

ก่อนที่จะลบโหนดแอตทริบิวต์:

Hello World

หลังจากลบโหนดแอตทริบิวต์:

Hello World

ลองตัวเอง»

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

removeAttributeNode() วิธีการเอา specified แอตทริบิวต์จากองค์ประกอบและส่งกลับ removed แอตทริบิวต์เป็น วัตถุ attr โหนด

ความแตกต่างระหว่างวิธีการนี้และ removeAttribute() วิธีการเป็นที่ removeAttribute() วิธีการเอาแอตทริบิวต์ที่มีชื่อระบุไว้ในขณะที่วิธีการนี้เอาวัตถุ attr ระบุ ผลที่ได้จะเหมือนกัน นอกจากนี้ removeAttribute() วิธีการมีค่าตอบแทนไม่ขณะที่วิธีการนี้จะส่งกลับ removed แอตทริบิวต์เป็นวัตถุ attr

เคล็ดลับ: ใช้ getAttributeNode() วิธีการที่จะกลับโหนดแอตทริบิวต์ขององค์ประกอบ

เคล็ดลับ: ใช้ setAttributeNode() วิธีการที่จะเพิ่มโหนดแอตทริบิวต์องค์ประกอบ


สนับสนุนเบราว์เซอร์

วิธี
removeAttributeNode() ใช่ ใช่ ใช่ ใช่ ใช่

วากยสัมพันธ์

element .removeAttributeNode( attributenode )

ค่าพารามิเตอร์

พารามิเตอร์ ชนิด ลักษณะ
attributenode Attr object จำเป็นต้องใช้ โหนดแอตทริบิวต์คุณต้องการลบ

รายละเอียดทางเทคนิค

กลับค่า: วัตถุ attr แทนที่ removed โหนดแอตทริบิวต์
DOM รุ่น หลักระดับ 1 ธาตุวัตถุ

ตัวอย่าง

ตัวอย่างอื่น ๆ

ตัวอย่าง

ถอด href โหนดแอตทริบิวต์จาก <a> องค์ประกอบ:

var elmnt = document.getElementById("myAnchor");   // Get the <a> element with id="myAnchor"
var attr = elmnt.getAttributeNode("href");         // Get the href attribute node from <a>
elmnt.removeAttributeNode(attr);                   // Remove the href attribute node from <a>

ก่อนที่จะลบโหนดแอตทริบิวต์:

หลังจากลบโหนดแอตทริบิวต์:

Go to w3ii.com
ลองตัวเอง»

หน้าเว็บที่เกี่ยวข้อง

HTML Tutorial: แอตทริบิวต์ HTML

HTML DOM อ้างอิง: ใช้ HTML DOM Attribute วัตถุ

HTML DOM อ้างอิง: href="met_element_removeattribute.html"> removeAttribute() Method

HTML DOM อ้างอิง: href="met_element_getattributenode.html"> getAttributeNode() Method

HTML DOM อ้างอิง: href="met_element_setattributenode.html"> setAttributeNode() Method


<ธาตุวัตถุ