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

how to check if a value has changed in javascript webbrowser

PHPz
Release: 2024-07-19 09:52:26
Original
566 people have browsed it

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
Copy after login

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
}
Copy after login

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!

source:dev.to
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template