Home > front end >  Help!!!!!!!!!!!!!! Jq in each of the (), how to revise the color of each node?
Help!!!!!!!!!!!!!! Jq in each of the (), how to revise the color of each node?

Time:09-23

Code code
 
$(" site - doc - icon. Li layui - anim "). Each (function () {
This. Style. SetProperty (" background - color ", "# FFFF00", "important");
})


The background color of the above can't modify the corresponding this
Only each loop was over all this changes the background color in


How to do revise style every cycle, inquire

CodePudding user response:

The middle switch to
This. Style. BackgroundColor='# FFFF00'
Also not line

CodePudding user response:

 $(" site - doc - icon. Li layui - anim "). Each (function () {
$(this). The CSS ({" background - the color ", "# FFFF00! important;" });
})

CodePudding user response:

Can not be real-time is what meaning, how long will it take to get the cycle you finish?

CodePudding user response:

The
Hello World reference 3 floor, response:
what meaning is not real-time, how long will it take to get the cycle you finish?


I want to achieve a flow chart, this corresponds to the background execution method, complete a, will amend the current corresponding node this color this


How long time is not the key, the key is to every cycle, change the background color of a corresponding node that

CodePudding user response:

To cooperate with the background process can use the ajax callback

CodePudding user response:

The
Hello World reference 5 floor, response:
to match the background progress can use the ajax callback


With a callback, perform ajax in each loop, the callback is successful, I will change background color

But actually, the color of callback node success doesn't change

But after the full circulation, such as color to a unified change to come over

CodePudding user response:

May be your cycle is over, the background data hasn't arrived

CodePudding user response:

I've said in the last post, page rendering thread with js application threads are mutually exclusive,
You must end current js program after every change a color thread, to create a new application thread to perform the next revision,

Your ajax is synchronous, synchronization is done within a program thread, so want to asynchronous,

Again, both for loop and the each () traversal can only in a js program thread to finish, so can't use,
To use an asynchronous ajax + recursive functions,

CodePudding user response:

 
Var a=$(" site - doc - icon. Li layui - anim ");
var index=0;
(function loop () {
If (index$. Ajax ({
Url: XXXXXXXXXXXXXX ", "
Type: "POST",
Async: true,
Success: the function (data) {
A [index]. Style. SetProperty (" background - color ", "# FFFF00", "important");
index++;
Loop ();
}
});
}
}) ();
  • Related