I have this code on a website and want to change the text inside the class .payment_content but there are others with this class, so i need to point this selector by the ID #payment-option-5-container : What’s the best aproach to do this?
<div id="payment-option-5-container" class="payment-option">
<div class="payment_input">
<input type="radio" id="payment-option-5" name="payment-option" class="payment_radio not_unifrom not_uniform" data-module-name="" data-force-display="0">
<input type="hidden" id="url_module_payment_129">
</div>
<div class="payment_content">
<span>**Change this text**</span>
</div>
</div>
2
Answers
Use a
querySelector()
where you first select by id:#payment-option-5-container
and then inside (>
) the class.payment_content
.This demo shows the effect of
textContext
on destroying the DOM in comparison withinnerText
: