Kun*_*Lun -2 javascript jquery
我有这段 javascript:
jQuery(document).ready(function(){
const select = $('...'); //it's a simple select
const input = $('...'); //it's a simple input
select.change(doSomething());
input.change(doSomething());
function doSomething(){
console.log("yes");
}
}
Run Code Online (Sandbox Code Playgroud)
yes当页面加载时,在控制台打印两次。
当我更改 select 或 input 的值时yes,控制台不再打印。
jquery version: 3.4.0
您应该将doSomething函数传递给更改参数。不是它的执行结果。
select.change(doSomething);
input.change(doSomething);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31 次 |
| 最近记录: |