Javascript how to change radio button label text?

后端 未结 3 1785
你的背包
你的背包 2020-12-12 07:53

I want to change the text of the label which is associated with the radiobutton id=\"male\". I have tried various ways to do it, but i can\'t make it work. I want to change

3条回答
  •  不知归路
    2020-12-12 08:26

    You can use

    var r = document.getElementsByTagName("label")   
    

    to select all the label element in your page and then use

    r[0].innerHTML ="new text" 
    

    to select first label and set the text to "next text" in your test() function

提交回复
热议问题