It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

innerHTML NOT displaying

innerHTML NOT displaying

Postby hiyatran on Sun Sep 18, 2011 2:57 pm

innerHTML Not Displaying

I can't seem to get my innerHTML to display my content.

This works fine, if I was to put it all in one line.
Code: Select all
document.getElementById('addedText').innerHTML =  '<table><tr><td>'+"My text goes here"+'</tr></td></table>';


If I was to break it up, which I wanted then nothing seem to show up.
Code: Select all
   document.getElementById('addedText').innerHTML = '<table><tr><td>';
   document.getElementById('addedText').innerHTML = "My text goes here";
   document.getElementById('addedText').innerHTML = '</tr></td></table>';



Here's my code
Code: Select all
<html>
<head>
<script type="text/javascript">
function display() {
   document.getElementById('addedText').innerHTML = '<table border=1><tr><td>';
   document.getElementById('addedText').innerHTML = "My text goes here";
   document.getElementById('addedText').innerHTML = '</tr></td></table>';
}
</script>
</head>

<body onload="display()">
<div id="addedText"></div>
</body>
</html>


thanks
hiyatran
 
Posts: 18
Joined: Mon Jun 21, 2010 1:53 am

Re: innerHTML NOT displaying

Postby guillem on Sun Sep 18, 2011 5:36 pm

the tr and td closings are swapped in both codes, dude!
you must first close the td and then the tr:

</td></tr>

maybe this is it.
have a nice day
guillem
guillem
 
Posts: 3
Joined: Sat Sep 17, 2011 12:56 pm


Who is online

Users browsing this forum: No registered users and 5 guests