popup下拉菜单选择
问题描述:
这是我的下拉菜单。代码似乎没问题,没有错误,但它不会提示菜单中的选定项目。popup下拉菜单选择
$(document).ready(function() {
// this function is triggered as soon as something changes in the form
$("select[name='inptPAN']").change(function() {
//console.log('found change');
alert($(this).val());
});
}
HTML:
<div id='selectPopup'>
<form name='test'>
<select id='inptPAN' name='inptPAN'>
<option value='1'>item 1</option>
<option value='2'>item 2</option>
<option value='3'>item 3</option>
<option value='4'>item 4</option>
<option value='5'>item 5</option>
<option value='6'>item 6</option>
</select>
</form>
</div>
答
没有错误,但它不会从菜单提示选择的项目。
没有小提琴包含错误,您可以在控制台中看到错误。
错误是:您缺少$(document).ready
的结尾。
语法是:
$(document).ready(function() {
});
试试这个:
的document.ready的$(document).ready(function() {
$("select[name='inptPAN']").change(function() {
alert($(this).val());
});
});
答
你没有正确地完成了功能
$(document).ready(function() {
// this function is triggered as soon as something changes in the form
$("select[name='inptPAN']").change(function() {
//console.log('found change');
alert($(this).val());
});
});//you missed it
答
语法是这里的问题..
$(document).ready(function() {
});
您必须关闭的document.ready函数的});
代替}
你的代码看起来应该是这样..
$(document).ready(function() {
$("select[name='inptPAN']").change(function() {
alert($(this).val());
});
});
答
你的代码是不完整的。把);
放在最后。像下面
$(document).ready(function() {
// this function is triggered as soon as something changes in the form
$("select[name='inptPAN']").change(function() {
//console.log('found change');
alert($(this).val());
});
});
答
$(document).ready(function() {
// this function is triggered as soon as something changes in the form
$("select[name='inptPAN']").change(function() {
//console.log('found change');
alert($(this).val());
});
});
+0
请避免添加代码只有答案,也注入了一些解释。 – rekaszeru
感谢,它是好的,将选择回答 –