慕仔8415870
2021-07-23 22:17
<button id = "id" type="button" name="a">你好,我是宝宝</button>
<script>
var att = document.getElementsByName("a");
att.setAttribute("class","one");
</script>
<style>
.one{
color: red;
}
<button id = "id" type="button" name="a" onclick="fun1">你好,我是宝宝</button>
<script>
function fun1(){
var att = document.getElementsByName("a");
att.setAttribute("class","one");
}
</script>
<style>
.one{
color: red;
}
JavaScript进阶篇
469390 学习 · 22585 问题
相似问题