gpt4 book ai didi

javascript - 防止页面加载时触发 Onchange 事件

转载 作者:行者123 更新时间:2023-12-03 02:30:52 26 4
gpt4 key购买 nike

我正在使用 Onchange 事件,它工作正常。但我希望它能够防止页面加载时触发。

$("#first").change(function(){
$("#salary").val(function () {
return $(this).find('option').filter(function () {
return $(this).prop('null');
}).val();
});
});

任何人都可以帮助使用此代码实现此目的吗?

提前致谢。

最佳答案

<html>
<head>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<script>
$( window ).on( "load", function() {
$("#first").change(function(){
$("#salary").val(function () {
return $(this).find('option').filter(function () {
return $(this).prop('null');
}).val();
});
});
});
</script>
</html>

关于javascript - 防止页面加载时触发 Onchange 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48745907/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com