我的HTML正文中有两个选择选项。当select选项之前有更改时,我会尝试更新select选项。
但是,我在浏览器控制台中看到以下错误
未捕获计划:未定义不是$(‘#TypeError’).selectmenu(“刷新”)上的函数;
HTML
<select name="service" id="service" class="default" tabindex="3" onchange="updatePlanInfo(this)"> <option value="" selected disabled>Service</option> <!-- Example of a hidden dropkick placeholder --> <option value="Hadoop">Hadoop</option> <option value="NoSQLDB">NOSQLDB</option> </select> <select name="plan" id="plan" class="default" tabindex="4" > <option value=""selected disabled>Plan</option> <option value="Free">Free</option> <option value="Small">Small</option> </select>
Javascript
function updatePlanInfo(servicename) alert(servicename); var newOptions = { "Option 1": "value1", "Option 2": "value2", "Option 3": "value3" var $el = $("#plan"); $el.empty(); // remove old options $.each(newOptions, function(value,key) { $el.append($("<option></option>") .attr("value", value).text(key));