By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,166 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,166 IT Pros & Developers. It's quick & easy.

insert a row into a DIV

mickey0
100+
P: 142
Hello folk,
I need to insert a 3 rows into DIV; i tried with
div = document.getElementById("yes");
var row = div.insertRow(-1);
............
but there isn't insertRow (it seems....). How Can I do?? How many ways?
thanks.
Expand|Select|Wrap|Line Numbers
  1. <table>
  2.    <div id="yes">   </div>
  3. </table>
  4.  
Jan 25 '08 #1
Share this Question
Share on Google+
5 Replies


gits
Expert Mod 5K+
P: 5,333
i think that would really produce invalid markup ... btw. simply set the innerHTML of the div ...

kind regards
Jan 25 '08 #2

mickey0
100+
P: 142
Sorry, but this doesn't work. How do?
Expand|Select|Wrap|Line Numbers
  1.   div = document.getElementById("yes");
  2.   div.innerHTML = "HELLO";
  3.  
  4. <table>
  5.    <div id="yes">   </div>
  6. </table>
  7.  
Problem is that <div> must be inside the table...and I have to find a way to put more than one line into the div; with this above Hello appear over my table (firefox) and it doesn't appear with IE6....
Jan 25 '08 #3

gits
Expert Mod 5K+
P: 5,333
why do you have use that div? it is not valid as direct child of a table ... you may use the tbody-tag of the table in case you need a container here ...

kind regards
Jan 25 '08 #4

mickey0
100+
P: 142
sorry but Does innerHTML method work properly with IE6?
div.innerHTML = " Hello <br />"; //seems don't work
Jan 26 '08 #5

gits
Expert Mod 5K+
P: 5,333
do you get an error in IE? you should add the tbody for a table too, the tbody contains the rows ... innerHTML works with IE but there might be a problem with tables ... since IE always require the tbody when appending tr-nodes dynamically.

kind regards
Jan 26 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.