简体   繁体   中英

Change label text inside an input field

I whant to change the payment label("UepaPay") to credit/debit card.The vendor donen't allow me to change the payment method name, so I thought maybe I could change it with JS but... The problem here is that I working on wordpress so i can't change much of the code that I got. I could change the label if have an ID or class but this is not the case. Look at the picture:

Label problem

¿Is a way to change the label text without having an id?

You can use the 'querySelelector' method to search for attributes.

 document.getElementById('change').addEventListener('click', () => { document.querySelector(['[for=payment-pay]']).innerHTML = 'Credit/Debit Card' })
 <label for='payment-pay'>Payment Pay</label> <button id='change'>Change to Credit/Debit Card</button>

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.

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