jquery - 在 document.ready 上触发一个 jQuery 函数
问题描述
我的 .change() 函数中有一些 Javascript,并希望在 .ready() 函数的函数中应用相同的代码。有什么方法可以实现这一点,而无需将代码复制并粘贴到函数中?
$('.selabw').change(function(){
let that = $(this);
let value = that.parent().next().prev().find('select').val();
console.log('"' + value + '"');
if(value == ''){
that.parent().next().find('input').removeClass('disabledBetrag').removeAttr('disabled');
} else {
that.parent().next().find('input').val('0,00');
that.parent().next().find('input').attr('disabled', 'true').addClass('disabledBetrag');
}
});
$(document).ready( function(){
// trigger $('.selabw').change(function(){}); ?
}
解决方案
推荐阅读
- python - Python直接将日期转换为日期时间
- java - 找不到资源文件夹中的文件
- amazon-web-services - hex(sha256(...)) 和 sha256(...) 之间的区别
- c++ - 将 int32 转换为 uint32 是无操作的吗?
- react-native - 编译的应用程序未在真实设备中加载
- apache-kafka - 卡夫卡为用户将消息存储在单个分区上?
- php - 列值不能为空
- ios - 尝试使用 codemagic 构建我的颤振应用程序时,“App.framework 不支持配置文件”
- javascript - 在 Nuxt 项目中引发 JavaScript 堆内存不足错误
- flutter - Windows 中出现缓慢的内容