javascript - 需要帮助组合 jQuery 函数
问题描述
就像标题说的那样,我需要一些帮助来组合两个 jQuery 函数。这似乎很简单,但我无法弄清楚。他们每个人都做同样的事情。如果有帮助,第二个函数的“updated_checkout”是一个 WooCommerce 回调。
$( window ).on( 'resize', function () {
// Do same thing as other function
});
jQuery( document ).on( 'updated_checkout', function () {
// Do same thing as other function
} );
解决方案
简单如:
function doTheSameThing() {
// Do same thing
}
$( window ).on( 'resize', doTheSameThing);
jQuery( document ).on( 'updated_checkout', doTheSameThing);
推荐阅读
- xcode - 无法在 iOS 模拟器上运行颤振应用程序。已经尝试了很多东西
- typescript - TypeScript 接口和动态键
- r - 如何根据单独数据框中的值计算数据框中的新列?
- firebase - Firestore 安全规则 get()。存在()
- python - 为什么 tkinter GUI 不能使用 pythonw 工作(为了隐藏命令行)?
- sublimetext3 - Sublime text3,一个文件图标 webpack icons
- bash - Bash 5 - 未找到 mapfile / readarray 命令
- c# - 无法转换 lambda 表达式,适用于一个项目,而不是另一个
- java - Java 14 上的 SeaGlassLookAndFeel
- javascript - TypeError:form.updateValueAndValidity 不是 Angular 中的函数