HTML:
<select id="country" multiple="multiple"><option>Albania</option><option>Bangladesh</option><option>China</option><option>India</option></select>
<a onclick="submit()">submit</a>
JS:
function submit(){
var selected = [];
$("#country option:selected").each(function(){
selected.push($(this).text());
});
alert(selected);
}
当我点击提交时,我正在获得&#34;对象不支持此操作&#34;错误!!任何解决方案?
答案 0 :(得分:2)
问题来自您的提交函数声明:将其替换为
submit = function() {
...
}