我有一个运行在.change()
. 但我想在 jquery 上运行相同的代码.ready()
,但它不起作用。
这是我的代码:
jQuery('.nhp-opts-select-hide-below').change(function(){
var option = jQuery('option:selected', this);
if(option.data('show').length > 0 || option.data('hide').length > 0){
jQuery(option.data('show')).each(function(){
if(jQuery(this).closest('tr').is(':hidden')){
jQuery(this).closest('tr').fadeIn('fast');
}
});
jQuery(option.data('hide')).each(function(){
if(jQuery(this).closest('tr').is(':visible')){
jQuery(this).closest('tr').fadeOut('fast');
}
});
}else{
jQuery(option.data('show')).each(function(){
if(jQuery(this).closest('tr').is(':visible')){
jQuery(this).closest('tr').fadeOut('fast');
}
});
jQuery(option.data('hide')).each(function(){
if(jQuery(this).closest('tr').is(':hidden')){
jQuery(this).closest('tr').fadeIn('fast');
}
});
}
});
请告诉我如何在 jquery 上运行上面的代码准备好了吗?