Basically I want to do this in Javascript: onclick { document.getElementById('label1').text = "Hello World"; } <label id="label1"></label> (pseudocode ^)
try innerHTML document.getElementById('label1').innerHTML = "Hello World"; HTH (I'm not 100% sure, thou...)
Hi CircusCircus, piCouli is correct - the advantage with his/her approach is that you can add formatting to the string like "<b>Hello World</b>";. With what you were doing originally, the correct statement would be document.getElementById('label1').innerText = "Hello World";. However the disadvantage of your original approach is that you CANNOT add formatting. HTH
That cannot be a correct statement, because .innerText is I.E. only. <LABEL id="label1" style="font-weight:bold;color:#f20"></LABEL><br> <A HREF='#' onclick="return setText('label1','Hello whirled');">CLICK</A> <SCRIPT type='text/javascript'> function setText(id, txt) { var elem; if( document.getElementById && (elem=document.getElementById(id)) ) { if( !elem.firstChild ) elem.appendChild( document.createTextNode( txt ) ); else elem.firstChild.data = txt; } return false; } </SCRIPT> Code (markup):