我们有一个 ajax 脚本,它获取一个单词并将一些相关数据加载到一个 div 标签中。
它工作正常,但我们想将预加载器(不带 jQuery)添加到 div 标签,我们尝试了 spin.js但它仅适用于整个页面,这就是我们所做的:(总结)
<head>
<script src="spin.min.js"></script>
</head>
<body>
<div id="data">
//data loads here
</div>
<script type="text/javascript" charset="utf-8">
var opts = {
lines: 13, // The number of lines to draw
length: 7, // The length of each line
width: 4, // The line thickness
radius: 28, // The radius of the inner circle
rotate: 0, // The rotation offset
color: '#000', // #rgb or #rrggbb
speed: 1, // Rounds per second
trail: 92, // 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('data');
var spinner = new Spinner(opts).spin(target);
</script>
</body>
怎么了?以及任何其他(和更好的)解决方案?