1、多个元素处理同一个事件,有共同的逻辑
let loginForm = $('#loginForm'); loginForm.on('focusin', '#phone,#password,#account,#phoneCode', function (event) { let targetId = event.currentTarget.id; let errorElement = $('#' + targetId + 'Error'); clearErrorText(errorElement); })
2、一个元素处理多个事件
loginBtn.on('click change mouseover', function () { phoneValidate(phone, phoneError); })