I have to clear the fields, or preferably send them a blank space in quotes ( ""
), when pressing the Delete button . This in order to give an appearance of being deleted and when clicking on it again, checkbox
the fields appear "clean".
This is my code:
function action(){
document.getElementById("name").innerHTML = "";
document.getElementById("age").innerHTML = "";
document.getElementById('visita1').style.display = 'none';
}
function mas1() {
if (document.getElementById('yesCheck1').checked) {
document.getElementById('visita1').style.display = 'block';
}
else document.getElementById('visita1').style.display = 'none';
}
<input type="checkbox" onclick="javascript:mas1();" name="yesno"
id="yesCheck1" > Visita 1</td>
<div id="visita1" style="display:block">
<h1>This is a Heading</h1>
<input type="text" name="name" id="name" value="Pedro">
<input type="text" name="age" id="age" value="34">
<button onclick="action()">Delete</button>
</div>
I would appreciate help with JavaScript, because I don't know JQuery at all.
Use
value
instead ofinnerHtml
since this modifies the element itself: