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

前端 未结 7 1530

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

    Jquery One-liners:

    ES6 + jQuery:

    $('#select').append([...Array(100).keys()].map((i,j) => `< option >${i}`))
    

    Lodash + jQuery:

    $('#select').append(_.range(100).map(function(i,j){ return $('

提交回复
热议问题