Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 asp 下拉列表。根据我的要求,我需要通过外部 java 脚本文件设置该下拉列表的值。这怎么可能?我不会使用document对象来获取下拉 ID。
document
如果您可以将选项值列表设置为 js 数组,那么您可以使用 jQuery 的$.each 方法来构建这样的下拉列表
HTML
<select id="drop"></select>
jQuery
var values = ['test1','test2','test3','test4','test5','test6']; $.each(values,function(i,val){ $('<option />').text(val).val(val).appendTo('#drop'); });
工作小提琴