displaying a list of numbers in a dropdown element using jQuery -
i created div shown , hidden when button clicked.
it has dropdown displays numbers 0 - 10. works fine first time, if close it, , reopen, drop down list populated twice, , keeps adding on 0-10 0-10 there.
is there way displays 0 - 10 once?
thanks
$("body").on("click", "#settingscontrol", function () { //$("#settings").css("display", "block"); $('#settings').slidetoggle('slow', function () { var maxallowed = []; maxallowed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; (var = 0; < maxallowed.length; i++) { $("#attempts").append($("<option />").val(i).html(i)); } }); });
clear dropdown empty()
function. remove child elements of parent element.
$("body").on("click", "#settingscontrol", function () { //$("#settings").css("display", "block"); $('#settings').slidetoggle('slow', function () { var maxallowed = []; maxallowed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; $("#attempts").empty(); (var = 0; < maxallowed.length; i++) { $("#attempts").append($("<option />").val(i).html(i)); } }); });
Comments
Post a Comment