<button class="btn btn-xs btn-warning revise">编辑</button>
var revise = document.getElementsByClassName("btn btn-xs btn-warning revise")[0];
revise.οnclick=function revise() {
revBackground.style.display="block";
}
或者
var revise = document.getElementsByClassName("revise");
revise[0].οnclick=function revise() {
revBackground.style.display="block";
}
注意点:
①getElementsByClassName 中的 “Class” 是大写。
②
截图来源:https://zhidao.baidu.com/question/619329632613629652.html
③
var revise = document.getElementsByClassName("btn btn-xs btn-warning revise")[0]
var revise = document.getElementsByClassName("revise")[0]
都可以