How to append text to input radio button? [Solved] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

How to append text to input radio button? [Solved]

Can we add text without adding another element? https://code.sololearn.com/Wm5PBpeRdiuf/?ref=app

13th Oct 2020, 3:15 PM
Kashyap Kumar
Kashyap Kumar - avatar
5 Answers
+ 3
Use value attribute inside radio. Whatever inside value will be shown. <input type="radio" id="inp" value="option1"/>
13th Oct 2020, 3:20 PM
Steve Sajeev
Steve Sajeev - avatar
+ 3
You can use label. But you will have to add another element <input type="radio" id="male" name="gender" value="male"> <label for="male">Male</label><br>
13th Oct 2020, 3:27 PM
Steve Sajeev
Steve Sajeev - avatar
+ 3
Steve Sajeev you are using HTML, that's not what I want, I am trying using javascript.
13th Oct 2020, 3:31 PM
Kashyap Kumar
Kashyap Kumar - avatar
+ 2
inp.outerHTML= `<input type="radio" /> myRadioButton`;
13th Oct 2020, 3:42 PM
🇮🇳Vivek🇮🇳
🇮🇳Vivek🇮🇳 - avatar
0
Steve Sajeev using javascript, check the code, nevertheless value would not work as it's radio button
13th Oct 2020, 3:22 PM
Kashyap Kumar
Kashyap Kumar - avatar