Search code examples
htmlradio-buttonlabelprototypejsinnerhtml

How update a innerHTML of a <label> in Prototype by "for" attribute?


I have this radio generate by a framework, how update the "asa" text from label whithout id but with "for" attribute?

<input type="radio" value="questao1" id="SimuladoQuestao1">
        <label for="SimuladoQuestao1">asa</label>

Thanks, Celso.


Solution

  • Prototype has a very strong selector engine. This is one way of doing it:

    $$('label[for="SimuladoQuestao1"]').first().update('New label')
    

    See details here