Home  >  Article  >  Web Front-end  >  how to check if a value has changed in javascript webbrowser

how to check if a value has changed in javascript webbrowser

PHPz
PHPzOriginal
2024-07-19 09:52:26494browse

how to check if a value has changed in javascript webbrowser

do

var old = /*value*/
function loop(){
 if (/*value*/ != old){ //check if the value is not old
  //do stuff
 }
 old = /*value*/ //set old to value
 requestAnimationFrame(loop) //loop every frame
}
requestAnimationFrame(loop) //wait a frame

or

var old = /*value*/
function changed(){
 var change = /*value*/ != old //check if the value is not old
 old = /*value*/ //set old to value
 return change //output change
}

and replace /*value*/ with the value to check :)

The above is the detailed content of how to check if a value has changed in javascript webbrowser. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn