If you just want to clear the contents of the span, use this code:
document.getElementById("spnFirstName").innerHTML = '';
If you want to hide the span, use the following code:
document.getElementById("spnFirstName").style.display = '';
I am adding code to show some demonstration:
Use the following Java Script:
function resettextbox(val) {
document.getElementById("spnFirstName").innerHTML = val;
document.getElementById("spnSecondName").innerHTML = val;
}
function showhidetextbox(val) {
document.getElementById("spnFirstName").style.display = val;
document.getElementById("spnSecondName").style.display = val;
}
Use the following aspx code:
<div>
<input type="button" value="HIDE" onclick="showhidetextbox('none');" />
<input type="button" value="Show" onclick="showhidetextbox('');" />
<input type="button" value="Clear" onclick="resettextbox('');" />
<input type="button" value="Set" onclick="resettextbox('Value');" />
<span id="spnFirstName" style="color: red">1</span>
<span id="spnSecondName" style="color: red">2</span>
</div>