使用显示平面的包装器和包含任何文本的内部元素;
<的空格/ em>的每个字母的启动时间稍微延迟到包装器的中心,保持在那里,然后离开视口。我个人这样做是为了加载动画。
<div class="LoadWrap">
<div class="Loading">Loading</div>
</div>
<script type="text/javascript" src="Assets/JS/jquery-3.1.1.js"></script>
<script type="text/javascript" src="Assets/JS/jquery-ui-1.12.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var Elem = $('.Loading'),
EWid = Elem.width(),
EStr = Elem.html(),
ESLe = EStr.length,
EOWi = Elem.parent().width(),
ABCD = (EOWi - EWid) / 2,
CTWi = 0;
Elem.html("");
for (var i = 0, len = ESLe; i < len; i++) {
Elem.append("<div style=\"margin-left: " + EOWi + "px;\">" + EStr[i] + "</div>");
}
for (var i = 0, len = ESLe; i < len; i++) {
var ThisWidth = $(".Loading > div:nth-of-type(i)").width();
console.log(ThisWidth);
//setTimeout(
// function() {
// $("#full-wrapper #full").animate({
// marginLeft: '-=938px'
// },{
// easing: 'easing',
// duration: 250,
// });
// }, 500);
}
});
</script>
:nth-of-type(i)
不会。答案 0 :(得分:1)
您需要连接数字
var ThisWidth = $(".Loading > div:nth-of-type(" + i + ")").width();