简体   繁体   English

我该如何添加<p>用于包装联系表格 7 响应消息的标签?</p>

[英]How can i add <p> tags to wrap contact form 7 response message?

I am implementing the new tag manager update on a contact 7 form.我正在联系人 7 表单上实施新的标签管理器更新。 It works adding some attributes to the div containing the response message.它可以向包含响应消息的div添加一些属性。 My problem is that the text of the response must be wrapped inside <p> tags and those tags must also be wrapped by the div .我的问题是响应的文本必须包含在<p>标签内,并且这些标签也必须由div包装。

- This is the div before submitting the form: - 这是提交表单之前的div

<div class="wpcf7-response-output" aria-hidden="true"></div>

- And this is the same div after the form is submitted , Note that the values of the attributes of the div are changed for privacy issues. - 这是提交表单后的同一个div ,注意div的属性值是为了隐私问题而改变的。

<div class="wpcf7-response-output" aria-hidden="true" data-gtm-vis-recent-on-screen-99999999_9="9999999" 
data-gtm-vis-total-visible-time-99999999_9="100" data-gtm-vis-has-fired-9999999_9="1" data-gtm-vis-first-on-screen-999999_9="9999999" › Su mensaje se ha enviado con éxito. Muchas gracias. </div>

- This is what a need (edited in chrome dev tools - 这是需要的(在 chrome 开发工具中编辑

<div class="wpcf7-response-output" aria-hidden="true" data-gtm-vis-recent-on-screen-99999999_9="9999999"
data-gtm-vis-total-visible-time-99999999_9="100" data-gtm-vis-has-fired-9999999_9="1" data-gtm-vis-first-on-screen-999999_9="9999999" >
<p>
Su mensaje se ha enviado con éxito. Muchas gracias.
</p>
</div>

Thanks in advance for your help.在此先感谢您的帮助。

You can try innerHTML.你可以试试innerHTML。

<div class="wpcf7-response-output" aria-hidden="true"data-gtm-vis-recent-on-        
screen-99999999_9="9999999" 
data-gtm-vis-total-visible-time-99999999_9="100" data-gtm-vis-has-fired- 
9999999_9="1" data-gtm-vis-first-on-screen-999999_9="9999999"> 
Su mensaje se ha enviado con éxito. Muchas gracias. 
</div>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
    document.querySelector(".wpcf7-response-output").innerHTML = 
    "<p>Su mensaje se ha enviado con éxito. Muchas gracias. <p/>";
    }
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM