I'm looking at this question post, and I'm having trouble applying it to work in my code.
It's confusing me because I'm doing the exact same thing for the save button as I am the cancel button (at least, the part about it closing) and nothing happens upon clicking cancel.
<dialog class="my-modal">
<p>Add Cust</p>
<label for="nameField">Name</label><input id=nameField><br>
<label for="addressField">Address</label><input id=addressField><br>
<label for="cityField">City</label><input id=cityField><br>
<label for="stateField">State</label><input id=stateField size=2>
<label for="zipField">Zip</label><input id=zipField><br>
<br>
<button onclick="closeAndSave()">Save</button>
<button onclick="close()">cancel</button>
</dialog>
function close(){
const modal = document.querySelector('.my-modal');
modal.close();
}
Have also tried:
<button class="btn btn-default" data-dismiss="my-modal" aria-label="Close">Cancel</button>