我有一个包含text input
和submit button
的HTML页面。
<form name="form1" onsubmit="startSpinner()">
<input type="text" name="fname" >
<input type="submit" value="Submit">
</form>
我正在spin.js
函数
startSpinner
创建一个微调器
function startSpinner() {
var opts = {
lines: 17, // The number of lines to draw
length: 30, // The length of each line
width: 20, // The line thickness
radius: 60, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 90, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#000', // #rgb or #rrggbb or array of colors
speed: 0.8, // Rounds per second
trail: 33, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: 'auto', // Top position relative to parent in px
left: 'auto' // Left position relative to parent in px
};
var target = document.getElementById('spinner_span');
var spinner = new Spinner(opts).spin(target);
}
当我点击Submit
时,微调器短暂地(约1秒)然后停止。我检查了控制台 - 微调器对象不再在范围内。我做错了什么?