Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
165
rated 0 times [  168] [ 3]  / answers: 1 / hits: 36884  / 12 Years ago, fri, september 28, 2012, 12:00:00

I want to clear a value of a span inside a div without deleteing other contents only the contents of a span.



ex:
body:



<div id=content>
<span>one</span>

<input type=text />
<input type=text />

<span>two</span>
<span>three</span>

<select>
<option selected=selected value=></option>
<option value=Monday>Monday</option>
<option value=Tuesday>Tuesday</option>
<option value=Wednesday>Wednesday</option>
<option value=Thursday>Thursday</option>
<option value=Friday>Friday</option>
<option value=Saturday>Saturday</option>
<option value=Sunday>Sunday</option>
</select>
</div>


script:



<script type=text/javascript>
function restSel() {
document.getElementById(#content span).innerHTML=;
};
</script>


Clear all the spans or the content of all the spans.


More From » html

 Answers
73

If you were using JQuery ( which will bring you much joy ), then you could do it like this.



$(span).html();

[#82865] Wednesday, September 26, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marquezb

Total Points: 237
Total Questions: 97
Total Answers: 89

Location: Israel
Member since Wed, Apr 14, 2021
3 Years ago
;