شرح صفوف ومحتوى الفقرة
تستخدم دالة ()removeAttribute في لغة جافا سكريبت لحذف خاصية من عنصر موجود داخل شجرة DOM Tree من صفحة HTML ولكن يجب عليك تحديد العنصر أولاً الزي تريد حذفة الخاصية منه.
removeAttribute() method Syntax
كيف تكتب دالة [ removeAttribute] removeAttribute() method Syntax؟
HTML
Element.removeAttribute('attributeName');
removeAttribute Parameters معطيات أو عوامل دالة ()removeAttribute في لغة جافا سكريبت:
دالة ()removeAttribute نقوم بتمرير لها عامل واحد فقط:
- Attribute Name وهو اسم الخاصية المراد حذفها من أي عنصر محدد داخل صفحة HTML بلغة جافا سكريبت.
removeAttribute from element
يمكنك حذف خاصية attribute من أي عنصر داخل الشجرة عن طريق دالة ()removeAttribute.
HTML
let apple = document.getElementById('apple');
let button = document.getElementById('button');
let p = document.getElementById('p');
button.addEventListener("click",()=>{
apple.removeAttribute("class");
p.innerText = "class name now is " + p.getAttribute("class");
});