javascript - 点击按钮 增加多个类
本文介绍了javascript - 点击按钮 增加多个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
获得id为week的按钮 点击按钮的时候,希望按钮增加多个类名,jquery好实现,那js除了这样一个一个的加还有没有比较方便的方法么?
<script>
window.onload = week;
function week(){
var weeks = document.getElementById("week");
var table = document.getElementById("table");
var table2 = document.getElementById("table2");
var text = document.getElementById("text");
table2.className = fix;
weeks.onclick = function(){
weeks.className = 'show';
weeks.className = 'week';
table.className = 'fix';
}
text.change = function(){
weeks.className = 'fix';
weeks.className = 'week';
table.className = 'show';
}
}
</script>
解决方案
https://developer.mozilla.org...
这篇关于javascript - 点击按钮 增加多个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文