Reputation: 3
I'm trying to delete an html element using JavaScript when another html element reaches a certain height. But, it requires me to keep clicking the button that triggers the code to keep checking if the height of that element has changed. Is there anyway around this?
Upvotes: 0
Views: 540
Reputation:
try to check every interval of time.
function check() {
// do the checking here
}
// check every 30 ms
setInterval(check, 30);
Note: Do not use while statements because it blocks the rendering of the page until it is executed.
Upvotes: 1
Reputation: 7288
Use setInterval() and put your code there with interval time
var myInterval = setInterval(function(){
//your code or event trigger comes here
//when done clearInterval(myInterval)
}, 500);//each 0.5 second
Let me know if you want to know more or I explain wrong
Upvotes: 0
Reputation: 1520
Set an event listener on the object that checks the height, when the object reaches the specified height then the statement will be true and begin to execute which would simply just remove the object. Post your code and I'll help you out.
Upvotes: 1