WordPress 联系我们 7 代码无效
Wordpress Contact us 7 not code not working
我想在发送消息后隐藏联系表。
经过一些研究,我发现我必须在附加设置字段中添加额外的代码。
我找到了一个简单的解决方案:
on_sent_ok: "document.getElementById('asaphide').style.display = 'none';"
但它已被弃用。
然后我尝试了他们网站上的以下代码:
var wpcf7Elm = document.querySelector( '.wpcf7' );
wpcf7Elm.addEventListener( 'wpcf7submit', function( event ) {
alert( "Fire!" );
}, false );
但它也没有用。
我该怎么做?
像这样将事件侦听器添加到文档中:
document.addEventListener( 'wpcf7submit', function( event ) {
alert( "Fire!" );
}, false );
或者像 in the docs 一样,创建一个 div
放置此表单的位置:
Be aware that the event target (wpcf7Elm in the example) is not a form
element, but its parent div element that has a wpcf7 class.
我想在发送消息后隐藏联系表。 经过一些研究,我发现我必须在附加设置字段中添加额外的代码。
我找到了一个简单的解决方案:
on_sent_ok: "document.getElementById('asaphide').style.display = 'none';"
但它已被弃用。
然后我尝试了他们网站上的以下代码:
var wpcf7Elm = document.querySelector( '.wpcf7' );
wpcf7Elm.addEventListener( 'wpcf7submit', function( event ) {
alert( "Fire!" );
}, false );
但它也没有用。 我该怎么做?
像这样将事件侦听器添加到文档中:
document.addEventListener( 'wpcf7submit', function( event ) {
alert( "Fire!" );
}, false );
或者像 in the docs 一样,创建一个 div
放置此表单的位置:
Be aware that the event target (wpcf7Elm in the example) is not a form element, but its parent div element that has a wpcf7 class.