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

标签 javascript jquery wordpress

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',
    });

})

最佳答案

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

关于javascript - 提交表单后我的焦点并未从输入中移除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59070764/

相关文章:

javascript - 给定一个数字范围,显示标签而不是轴值?

javascript - AngularDart 4-5 变更检测与 Angular 5 变更检测有何不同?

javascript - 从 JavaScript 构造函数返回公共(public)接口(interface)

java - 可以在 Google App Engine 下运行的 WordPress 类似\克隆有哪些?

wordpress - 使用 ProxyPass 在负载均衡器后面将 Wordpress http 更改为 https

javascript - HTML5 fileWriter.write 不写入本地文件

c# - MVC3 和 Ajax : Refresh list to hide a record which was deleted from list by a button click

jquery - 如果 JQuery Mobile 内容溢出,如何通过滚动保持面板高度固定

jquery - 如何使用jquery实现按钮的悬停效果?

php - WooCommerce:在结帐页面中默认设置国家/地区