这是我的下拉菜单。代码似乎没问题,没有错误,但它不会从菜单中提醒所选项目。
$(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>
答案 0 :(得分:3)
你没有正确完成这项功能
$(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
答案 1 :(得分:3)
没有错误,但它不会从菜单中提醒所选项目。
没有小提琴包含错误,您可以在控制台中看到错误。
错误是:您遗漏了$(document).ready
的结尾。
语法是:
$(document).ready(function () {
});
试试这个:
$(document).ready(function () {
$("select[name='inptPAN']").change(function () {
alert($(this).val());
});
});
答案 2 :(得分:1)
document.ready的语法就是这里的问题..
$(document).ready(function () {
});
您必须使用});
代替}
您的代码应如下所示..
$(document).ready(function () {
$("select[name='inptPAN']").change(function () {
alert($(this).val());
});
});
答案 3 :(得分:1)
您的代码不完整。把);
放在最后。如下
$(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());
});
});
答案 4 :(得分:1)
$(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());
});
});