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

前端 未结 7 1529

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($('<option></option>').val(i).html(i))
        }
    });​
    

    -- SEE DEMO --

    You can download jQuery here

    0 讨论(0)
提交回复
热议问题