📌  相关文章
📜  如何在javascript代码示例中为选定元素添加属性

📅  最后修改于: 2022-03-11 15:02:02.983000             🧑  作者: Mango

代码示例1
// Selecting the element
    var btn = document.getElementById("myBtn");
    
    // Setting new attributes
    btn.setAttribute("class", "click-btn");
    btn.setAttribute("disabled", "");