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

前端 未结 7 1544

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:47

    Are you using JavaScript or jQuery besides the html? If you are, you can do something like:

    HTML:

    jQuery:

    var select = '';
    for (i=1;i<=100;i++){
        select += '';
    }
    $('#some_selector').html(select);
    

    As you can see here.

    Another option for compatible browsers instead of select, you can use is HTML5's input type=number:

    
    

提交回复
热议问题