javascript - Changing an html "for" label with java script -



javascript - Changing an html "for" label with java script -

i need alter "for" label extension using javascript. unsure how this. give thanks in advance help!

<input id="thecheckboxid" type="checkbox" name="thecheckboxname" /> <label for="thecheckbox">the text want change</label>

demo

first give label id

<label id="lbl1" for="thecheckbox">the text want change</label>

then do

document.getelementbyid("lbl1").setattribute("for", "thecheckboxid");

edit

wait, did want alter for value, or alter actual text of label? in event, here's how alter text:

if (label.textcontent) label.textcontent = "new text"; else if (label.innertext) label.innertext = "new text" else label.innerhtml = "new text";

javascript

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -