Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
46
rated 0 times [  51] [ 5]  / answers: 1 / hits: 31024  / 13 Years ago, wed, july 6, 2011, 12:00:00

Once a user enters lets say 5 numbers into that list I want to have a reset button so if the user wants to delete them all instantly they can click reset which should delete the entire list....



I have tried making a reset button with a reset function that fetches the element by id and tries to delete it but it did not quite work so I am hoping someone here knows how to do that...



here is the fiddle
http://jsfiddle.net/bikbouche1/QVUHU/67/


More From » html

 Answers
16

See this updated fiddle. Key code:



document.getElementById(reset).onclick = function() {
document.getElementById(numbers).innerHTML = ;
};


To clarify, since this appears to have confused other posters - the numbers div is a placeholder for one or more dynamically-created input elements, not a reference to the original number input. By setting innerHTML to , the above code deletes the dynamically created elements entirely - it's not trying to clear their values.


[#91328] Tuesday, July 5, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kalynnkathrynd

Total Points: 273
Total Questions: 101
Total Answers: 93

Location: Nauru
Member since Thu, Feb 2, 2023
1 Year ago
;