提交表单后,我的焦点并未从输入中移除

问题描述 投票:0回答:1
document.addEventListener( 'wpcf7mailsent', function( event ) {
  alert("ok");
     jQuery('input').focusout(function() {
        const label = $(this).parent().parent().find('label');
        if (jQuery(this).val() != '') return;
        label.animate({
          'font-size': '17px',
          'top': '10px',
        });

    })
}, false );

通过单击发送,如果发送成功,插件是否有事件wpcf7mailsent,那么我想从输入中删除焦点并将标签放到适当的位置,但是由于某种原因,它不起作用附言警报工作

这些只是通过单击输入对我有用的功能。标签在此上下移动

jQuery('input').focus(function() {
  const label = $(this).parent().parent().find('label');
  if (jQuery(this).val()=='') {
  label.animate({
    'top': '5px',
    'font-size': '75%',
  });
  } 
})
jQuery('input').focusout(function() {
    const label = $(this).parent().parent().find('label');
    console.log('Value ', jQuery(this).val());
     if (jQuery(this).val() != '') return;
    console.log('Passed if');
    label.animate({
      'font-size': '17px',
      'top': '10px',
    });

})
javascript jquery wordpress
1个回答
0
投票

尝试返回false,或者您可以在提交按钮上再次单击focustout(单击)

© www.soinside.com 2019 - 2024. All rights reserved.