jQuery - Stripping self-closing tags |
[eluser]Kyle Johnson[/eluser]
So I have been making some changes and cleaning up some code on an application but when I ran the xhtml validator I noticed that there are a lot of validation errors. I was quite confused! Well after looking at it, I noticed that in my code I am putting the close tag within the variable that will be added. Notice the self-closing of the input tag. Code: var newTR = "<tr class='item' id='item_"+countItemList+"'>" However, when I actually view the source, it does not have the self-close. The .append() method seems to strip that final tag. Code: <tr class="item r1" id="item_0"> How do I fix this? Any ideas? I have tried: // \/ \// They all just disappear.
[eluser]Kyle Johnson[/eluser]
***UPDATE*** Fixed it. Found a few interesting points regarding serving the page with the correct MIME type, as the browser determines what to parse the JavaScript as. http://keystonewebsites.com/articles/mime_type.php So by following the advice there, my tags are now properly closed according to the supplied standard. So by using this in a file: Code: <?php And then importing it: Code: <?php include("/path/filename.php"); ?> However, the above doesn't appear to work when using w3.org's validator as it tries to parse it using HTML 4.. This makes older browsers capable of generating the page (I think). However, adding the following code directly seems to bypass that problem: Code: <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n"; ?> |
Welcome Guest, Not a member yet? Register Sign In |