I am working on a simple Play and Pause button code with Javascript. The script is toggling the CSS property; however, after a delay. At the moment, the toggle happens on second click. Not sure what the issue is.
$(document).click(function () {
$("#startClock").click(function () {
$("#startClock").css("display", "none");
$("#stopClock").css("display", "block");
});
$("#stopClock").click(function () {
$("#stopClock").css("display", "none");
$("#startClock").css("display", "block");
});
});
#stopClock {
display: none;
}
#startClock {
display: block;
}
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js?ver=4.1'></script>
<button id=startClock >Start</button>
<button id=stopClock >Pause</button> <br/>