Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在document.ready上触发jQuery函数_Jquery - Fatal编程技术网

在document.ready上触发jQuery函数

在document.ready上触发jQuery函数,jquery,Jquery,我在.change()函数中有一点Javascript,希望在.ready()函数中应用相同的代码。有没有什么方法可以实现这一点,而不需要将代码复制粘贴到函数中 $('.selabw').change(function(){ let that = $(this); let value = that.parent().next().prev().find('select').val(); console.log('"' + value + '"'); i

我在.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(){}); ? 
}
你可以这样试试

$('.selabw').trigger('change')

请参阅此stackoverflow链接,很抱歉回复太晚。非常感谢你的回答。正是我需要的!