这个问题一直困扰着我一段时间。我无法使用spin.js处理提交按钮。
这是一个小提琴:
如果您注释掉提交按钮而不是允许div,那么它可以正常工作。
感谢。
供参考:
<input type="submit" id="spin">
var spinner;
var opts = {
lines: 13, // The number of lines to draw
length: 5, // The length of each line
width: 2, // The line thickness
radius:5, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 58, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#fff', // #rgb or #rrggbb or array of colors
speed: 0.9, // Rounds per second
trail: 100, // 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: '57%', // Top position relative to parent
left: '50%' // Left position relative to parent
};
var target = document.getElementById('spin');
var spinner = new Spinner(opts).spin(target);
$(target).data('spinner', spinner);
答案 0 :(得分:0)
正如评论中所解释的那样,提交按钮并不意味着包含其他元素。
这引发了问题的问题。
为了解决这个问题,我将提交按钮包装在宽度和高度相同的div中。
<div id="wrap">
<input type="submit">
</div>
答案 1 :(得分:0)
您可以使用<button>
元素,默认情况下用作提交按钮:
http://jsfiddle.net/fgnass/q6ou3dt7/