One button shows the user local time when clicked. Then I have another button that stops the clock. I am trying to disable "show local time" when the button "stop time" is clicked.
<button id="start" onclick="showTime()" >Show Local showTime</button> <button id="stop" onclick="myStop()">Stop Time</button>
This is my code in HTML
I've tried this for my javascript
document.getElementById(start).disabled = true; document.getElementById(stop).removeAttribute('disabled')
Tried this
function showTime() {
document.getElementById("start").disabled = true;
}
function myStop() {
document.getElementById("stop").disabled = false;
}
None of these have works for disabling the other button. They both are being allowed to be clicked.
As far as I got the question, you need to disable one button when you click the other button. I will post an answer that will do the work.
function showTime() {
document.getElementById("stop").disabled = !document.getElementById("stop").disabled;
}
function myStop() {
document.getElementById("start").disabled = !document.getElementById("start").disabled;
}
When you click the show local time button,
stop time if stop time is enabledstop time if stop time is disabledWhen you click the stop time button,
show local time if show local time is enabledshow local time if show local time is disabled