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

problem with Firefox and change an element text

mickey0
100+
P: 142
Hi, I have some problems with this code that works with IE but don't with FF (see the comments):
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <script>
  3. function myFunc () {
  4.     var element = document.getElementById("intro");
  5.     alert("element " + element.innerHTML);   //in FF it  print an empty string
  6.     //element.innerHTML += "otherText"; //what code to do this ? (inside tbody  
  7.     //that doesn't work!)
  8. }   
  9. </script>
  10.  
  11. <head>
  12.  </head>
  13.  
  14.  <body onload="myFunc()">
  15.     <table>
  16.         <tbody id="intro"> Pages Title</tbody>
  17.     </table>
  18. </body>
  19. </html>
  20.  
Thanks
Jan 19 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 210
Expand|Select|Wrap|Line Numbers
  1. ]
  2. <table>
  3.         <tbody id="intro"> Pages Title</tbody>
  4.     </table>
  5. </body>
  6. </html>
  7.  
Try starting out with some valid table HTML:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type='text/javascript'>
  4. function myFunc ()
  5. {
  6.  var element = document.getElementById("intro");
  7.  alert("element " + element.innerHTML);   //in FF it  print an empty string
  8.  element.innerHTML += "otherText"; //what code to do this ? (inside tbody  
  9.  alert(element.innerHTML);
  10. }   
  11. </script>
  12. </head>
  13.  <body onload="myFunc()">
  14.    <table>
  15.      <tbody id="intro"><tr><td>Pages Title</td></tr></tbody>
  16.    </table>
  17. </body>
  18. </html>
Jan 20 '08 #2

Post your reply

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