Button Timeout

ساخت وبلاگ
Hi I'm new to coding and having trouble with some code.
I have a button which when pressed changes the battery icon to a text display of battery % remaining and when the button is pressed again reverts back to the battery icon.
What I'm trying to do is when the button is pressed the text display reverts back to the battery icon automatically after 5 seconds.
The javascript I have for the button is:

batBtn.onactivate = function(evt) {
if ( switcher === false) {
myBat.style.display = "none";
myBatIcn.style.display = "inline";
myBatRect.style.display = "inline";
switcher = true;
} else {
myBat.style.display = "inline";
myBatIcn.style.display = "none";
myBatRect.style.display = "none";
switcher = false; }
}
}

Any help is greatly appreciated.

Regards Assad
CodingForums...
ما را در سایت CodingForums دنبال می کنید

برچسب : نویسنده : codingforums بازدید : 137 تاريخ : جمعه 29 دی 1396 ساعت: 20:42