I need to do it without javascript .
For example, the form HTML rendered on the page normally looks like this:
<form action="/contact-us/#wpcf7-f713-p61-o1" method="post" class="wpcf7-form submitting" novalidate="novalidate" data-status="submitting">
But I need to add the custom attribue data.netlify="true"
so the form should end up like this:
<form action="/contact-us/#wpcf7-f713-p61-o1" method="post" class="wpcf7-form submitting" novalidate="novalidate" data-status="submitting" data-netlify="true">
There is a similar question over here . But that is for putting a custom attribute on the input, I need the custom attribute on the form itself.
If the action always is the same on the form you could use javascript to add it
<script>
var data = document.querySelector('[action="/contact-us/#wpcf7-f713-p61-o1"]');
data.setAttribute('data-netlify', true);
console.log(data);
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.