我正在尝试为HTML代码中的某些元素创建加载动画栏,该动画栏通过单击按钮触发 以下是javascript代码,我遇到了错误
// I have used the following HTML code to run the below "move" function
<button class="w3-button w3-black" onclick="move()">Click Here To Check</button>
//On clicking the button the bar does not animate.
function move() {
/* 9 different loading bars */
var name =["mybar1","mybar2","mybar3","mybar4","mybar5","mybar6","mybar7","mybar8","mybar9"];
var text="";
var i;
for (i=0 ; i < name.length ; i++)
{
text = name[i] + "<br>";
}
document.getElementByName("name").innerHTML = text;
var elem = document.getElementByName("name");
var width = 0;
var id = setInterval(frame, 15);
function frame()
{
if (width >= 80) {
clearInterval(id);
} else {
width++;
elem.style.width = width + '%';
elem.innerHTML = width * 1 + '%';
}
}
}