【问题标题】:Change on send ok for javascript更改发送 ok 为 javascript
【发布时间】:2019-09-24 23:32:58
【问题描述】:

on_sent_ok 的代码不起作用,我该如何将其更改为 javascript。

on_sent_ok:"document.getElementById('formulariocontacto').style.display='none';"
on_sent_ok: "document.getElementById('formExtra').style.display='block';"

【问题讨论】:

    标签: javascript wordpress contact-form-7


    【解决方案1】:

    用 DOM 事件替换 on_sent_ok。

    在你的functions.php文件中添加这个简单的脚本:

    add_action( 'wp_footer', 'mycustom_wp_footer' );
    
    function mycustom_wp_footer() {
    ?>
    <script type="text/javascript">
    document.addEventListener( 'wpcf7mailsent', function( event ) {
        document.getElementById('formulariocontacto').style.display='none'; 
        document.getElementById('formExtra').style.display='block';
    }, false );
    </script>
    <?php
    }
    

    【讨论】:

    • 联系表单给我一个错误:使用了不推荐使用的设置。
    • 我现在在contact-form7页面中阅读...我更正了我的解决方案..稍等
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-06
    • 2010-12-14
    • 2018-05-08
    • 2020-09-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多