How to append text to input radio button? [Solved] | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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