问题
I'm trying to add a spinner to an onclick event and I cannot find a pure javaScript spinner. is this possible or is there a better way in grails?
回答1:
Pure javascript — not even any images:
document.getElementById("button").onclick = function() {
var spinner = document.getElementById("spinner_container");
spinner.anim_mode = 0;
var animation = ["|", "/", "–", "\\"]
var spin = function() {
spinner.anim_mode = (spinner.anim_mode + 1) % animation.length;
spinner.innerHTML = animation[spinner.anim_mode];
};
spin();
setInterval(spin, 100);
};
http://jsfiddle.net/dGL8X/
回答2:
This is my favorite go-to spinner. JS/CSS, no images. Has fallback for crappy browsers ;)
http://fgnass.github.com/spin.js/
来源:https://stackoverflow.com/questions/12218994/javascript-spinner-for-grails