I have a radio button that needs to be dynamically updated from user input but the normal .val(), .text(), and .html() won’t work. How can I change the text of a radio button using jQuery or plain JavaScript?
I have a radio button that needs to be dynamically updated from user input
Share
A radio button doesn’t have text associated with it.
But if you have a
label tag / span tagnext to the radio option. then you can use.nextto access that element and change itstext/htmlDEMO
HTML:
or
JS:
Or you can use the below hack to change the text next to radio option. Note that the below code assumes that text is next to radio option.
DEMO