In the below code you cant add any new ids or class names.
If the user clicks the button then if the errorUL exists then I want to add a message to the existing li or create a new li and add the message. Either way I want to show the extra message. "The card has been declined for an unknown reason. Please contact support".
<button id = 'place_order'>button</button>
<ul class="woocommerce-error" role="alert">
<li>
The card has been declined for an unknown reason.</li>
</ul>
<Script>document.getElementById('place_order').onclick = function() {
var errorUl = document.getElementsByClassName('woocommerce-error');
if(errorUl.length > 0) {
{{NEED to access the li and add a message}}
}
}</Script>
2
Answers
You change the elements text like this:
This is the answer