Click to See Complete Forum and Search --> : innerHTML vs innerText
Howdy, I'm reading my reference on JavaScript and the desciptions on innerHTML, innerText and outerHTML, outerText are identical. I get the difference between the inner and outer functions but what is the difference between the Text and HTML versions of these functions?
Regards,
- Tim
First of all, innerText and outerText only work in IE, but innerHTML and outerHTML both work in IE and Netscape. Also, innerText does not render HTML, where innerHTML will.
Jona
khalidali63
05-30-2003, 01:53 PM
ok try these two lines of code with some Ok try the code below,I am positive it will clear the difference.
<script type="text/javascript">
<!--
function Process(val){
var obj = document.getElementById("div_1");
if(val==1){
obj.innerText = "<h4 style='color:blue;'>Some Text</h4>";
}else{
obj.innerHTML = "<h4 style='color:blue;'>Some Text</h4>";
}
}
//-->
</script>
</head>
<body class="body">
<div id="div_1">
</div>
<form id="form1" action="" onsubmit="">
<input type="text" name="t1"/>
<input type="button" value="innerText" onclick="Process(1)"/>
<input type="button" value="innerHTML" onclick="Process(2)"/>
</form>
Thanks guys. Those were both great posts. Exactly the info I was looking for!
Best Regards,
- Tim :D
(Answering for Khalid as well as myself.) Sure thing! ;)
:D Jona
khalidali63
05-30-2003, 03:40 PM
lol..Sure man..( to jona)