json返回的数据:
var json = { "2211":"内容1", "2212":"内容2", "2213":"内容3", "2214":"内容4" }
javascript:
window.onload=function(){ $.each(json,function(i,n){ $(‘#Select‘).append(‘<option value=‘+i+‘>‘+n+‘</option>‘) }) var options=$("#Select option:selected"); $("#Select option").click(function(){ console.log(options.val()); alert(options.val()) }) }
html:
<select id="Select" > </select>
时间: 2024-12-29 23:40:43