一般如何定义下拉选项,以便我们可以为其分配另一个选项

How to define dropdowns options in general so that we can assign it another one

我有超过 10 个 drop-downs.They 都包含相同的值。我不想为超过 10 个选项定义它 times.So 有什么方法可以只定义一次吗?我的意思是有没有什么方法我们也可以用一般方式定义它?

例如

<select id='monday_1'></select>
<select id='monday_2'></select>
<select id='tuesday_1'></select>
<select id='tuesday_2'></select>

这里有选项,例如 01:00 AM、01:15 AM、01:30 AM 等... 有没有什么办法可以用一般方式定义它,以便我们可以将它分配给所有下拉菜单。

与Jquery:

$(function() {
  var time = ['01:00 AM', '01:15 AM', '01:30 AM'];
  $('select.time').html('<option>' + time.join('</option><option>') + '</option>');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<select id='monday_1' class='time'></select>
<select id='monday_2' class='time'></select>
<select id='tuesday_1' class='time'></select>
<select id='tuesday_2' class='time'></select>

没有Jquery:

var time = ['01:00 AM', '01:15 AM', '01:30 AM'];
var html = '<option>' + time.join('</option><option>') + '</option>';
var dd = document.getElementsByClassName('time');
var l = dd.length;
while (l--)
  dd[l].innerHTML = html;
<select id='monday_1' class='time'></select>
<select id='monday_2' class='time'></select>
<select id='tuesday_1' class='time'></select>
<select id='tuesday_2' class='time'></select>