我有Im在Lazy Line Painter中使用的JS代码,我试图使其按顺序运行。我尝试了不同的方法,但没有一个起作用。有人可以告诉我是否可以按顺序运行此代码。
码:
$(document).ready(function(){
$('#SEO_seo').lazylinepainter(
{
"svgData": pathObj8,
"strokeWidth": 2,
"strokeColor": "black"
}).lazylinepainter('paint');
$('#SEO_internet').lazylinepainter(
{
"svgData": pathObj6,
"strokeWidth": 2,
"strokeColor": "#2b357a"
}).lazylinepainter('paint');
$('#SEO_optmization').lazylinepainter(
{
"svgData": pathObj5,
"strokeWidth": 2,
"strokeColor": "#3999b2"
}).lazylinepainter('paint');
});
$(document).ready(function(){
$('#SEO_marketing').lazylinepainter(
{
"svgData": pathObj3,
"strokeWidth": 2,
"strokeColor": "#35a245"
}).lazylinepainter('paint');
});
$(document).ready(function(){
$('#SEO_html').lazylinepainter(
{
"svgData": pathObj4,
"strokeWidth": 2,
"strokeColor": "#075e33"
}).lazylinepainter('paint');
});
$(document).ready(function(){
$('#SEO_web').lazylinepainter(
{
"svgData": pathObj1,
"strokeWidth": 2,
"strokeColor": "#b51d2a"
}).lazylinepainter('paint');
});
$(document).ready(function(){
$('#SEO_mobile_blog').lazylinepainter(
{
"svgData": pathObj2,
"strokeWidth": 2,
"strokeColor": "#da5125"
}).lazylinepainter('paint');
});
$(document).ready(function(){
$('#SEO_rank').lazylinepainter(
{
"svgData": pathObj7,
"strokeWidth": 2,
"strokeColor": "#8b2477"
}).lazylinepainter('paint');
});
$(document).ready(function(){
$('#SEO_design').lazylinepainter(
{
"svgData": pathObj,
"strokeWidth": 2,
"strokeColor": "#cf1c53"
}).lazylinepainter('paint');
});
最佳答案
使用Lazy Line Painter的回调功能,如下所示:
$(document).ready(function(){
/ *定义所有回调* /
var function8 = function(){
$('#SEO_design')。lazylinepainter(
{
“ svgData”:pathObj,
“ strokeWidth”:2
“ strokeColor”:“#cf1c53”
})。lazylinepainter('paint');
};
var function7 = function(){
$('#SEO_rank')。lazylinepainter(
{
“ svgData”:pathObj7,
“ strokeWidth”:2
“ strokeColor”:“#8b2477”,
“ onComplete”:function8 //使用回调
})。lazylinepainter('paint');
};
var function6 = function(){
$('#SEO_mobile_blog')。lazylinepainter(
{
“ svgData”:pathObj2,
“ strokeWidth”:2
“ strokeColor”:“#da5125”,
“ onComplete”:function7 //使用回调
})。lazylinepainter('paint');
};
var function5 = function(){
$('#SEO_web')。lazylinepainter({
“ svgData”:pathObj1,
“ strokeWidth”:2
“ strokeColor”:“#b51d2a”,
“ onComplete”:function6 //使用回调
})。lazylinepainter('paint');
};
var function4 = function(){
+ $('#SEO_html')。lazylinepainter({
“ svgData”:pathObj4,
“ strokeWidth”:2
“ strokeColor”:“#075e33”,
“ onComplete”:function5 //使用回调
})。lazylinepainter('paint');
};
var function3 = function(){
$('#SEO_marketing')。lazylinepainter({
“ svgData”:pathObj3,
“ strokeWidth”:2
“ strokeColor”:“#35a245”,
“ onComplete”:function4 //使用回调
})。lazylinepainter('paint');
};
var function2 = function(){
$('#SEO_optmization')。lazylinepainter({
“ svgData”:pathObj5,
“ strokeWidth”:2
“ strokeColor”:“#3999b2”,
“ onComplete”:function3 //使用回调
})。lazylinepainter('paint');
};
var function1 = function(){
$('#SEO_internet')。lazylinepainter({
“ svgData”:pathObj6,
“ strokeWidth”:2
“ strokeColor”:“#2b357a”,
“ onComplete”:function2 //使用回调
})。lazylinepainter('paint');
};
$('#SEO_seo')。lazylinepainter({
“ svgData”:pathObj8,
“ strokeWidth”:2
“ strokeColor”:“黑色”,
“ onComplete”:function1 //使用回调
})。lazylinepainter('paint');
});
希望能帮助到你 !
关于javascript - 依次运行Js代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20141193/