When I click on this button, I want the value to change. When I do it, at first it changes the text on button, but the map does not appear. after that, I repeat the process and the code works fine.
function change() {
var elem = document.getElementById("myButton1");
if (elem.value == "Show") elem.value = "Hide";
else elem.value = "Show";
}
function displayMap() {
if (document.getElementById('map').style.display == "none") {
document.getElementById('map').style.display = "block";
initialize();
} else {
document.getElementById('map').style.display = "none";
}
}
#map {
display: none;
}
<input onclick='change(), displayMap()' type='button' value='Show' id='myButton1'></input>
<div id="map" style="width:100%; height:300px;">map</div>