It it not one line code. YOu have to handle manually all the change feature. Which means listen if the flag has changed or not from the outside. and then call your line of code. Which is not a good code anyway, we are in 2017, who use document.getElementById now….