Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2012
    Posts
    127
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Something funny!

    I have a simple table
    Code:
    <div id='myDiv'>
    <table border="1" ><tr><td>111</td><td>222</td></tr><tr><td>333</td><td>444</td></tr></table>
    </div>
    OK, but a noise makes it changed as below:
    Code:
    <div id='myDiv'>
    <table border="1" ><tr><td>111</td><td>222</td></tr><tr><t  d>333</td><td>444</td></tr></table>
    </div>
    Check and see that one <td> ---> <t d>
    Now I want to repair it. I prepare the js
    Code:
    <script type="text/javascript">
    var Str = document.getElementById('myDiv').innerHTML;
    Str = Str.replace('<t  d','<td');
    document.getElementById('myDiv').innerHTML = Str;
    </script>
    But strange enough, I only get the table string in order when the table is right. When table code is wrong, I can not get the string <table border="1" ><tr><td>111</td><td>222</td></tr><tr><t d>333</td><td>444</td></tr></table>
    but it is <td="">333</t><table border="1"><tbody><tr><td>111</td><td>222</td></tr><tr><td>444</td></tr></tbody></table>

    Any suggestion to get the code of table?
    Last edited by docco; 07-17-2013 at 09:59 AM.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,915
    Thanks
    6
    Thanked 1,040 Times in 1,013 Posts
    What kind of “solution” is that anyway? Where does that space come from? Why aren’t you removing that space at the root of the problem rather than superficially “fixing” something with (unreliable) JavaScript?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •