Easy way to add drop down menu with 1 - 100 without doing 100 different options?

前端 未结 7 1540

I was just wondering if there was a simple shortcut to add options to a dropdown menu for the numbers 1 to 100 instead of having to do the following:

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 05:48

    Not with plain HTML I'm afraid.

    You could use some jQuery to do this though:

    $(function(){
        var $select = $(".1-100");
        for (i=1;i<=100;i++){
            $select.append($('').val(i).html(i))
        }
    });​
    

    -- SEE DEMO --

    You can download jQuery here

提交回复
热议问题