html - How to set innerText in JavaScript for Chrome? -
i trying set innertext between element's start , end tag in chrome, far not working. why that? have tried these:
element.balancetext = "changed."; element.innertext = "changed."; element.innerhtml = "changed."; element.textcontent = "changed."; element.value = "changed."; $(element).val("changed.");
here fiddle: http://jsfiddle.net/la1tadpd/
your jsfiddle configured utilize coffee script not plain javascript, , because of this, you're getting error:
uncaught syntaxerror: reserved word "var"
due input tag beingness invalid html, suggest removing additional text node browser creates, replace input element div containing text want:
class="snippet-code-js lang-js prettyprint-override">var element = document.getelementbyid('test'); element.nextsibling.parentnode.removechild(element.nextsibling); var div = document.createelement('div'); div.textcontent = 'changed.'; element.parentnode.replacechild(div, element);
class="snippet-code-html lang-html prettyprint-override"><input id='test'>hello</input>
javascript html google-chrome text innertext
No comments:
Post a Comment