Forum Moderators: open

Message Too Old, No Replies

jQuery and validation

W3 validator seeming to pick and choose code

         

caffinated

6:01 am on Sep 28, 2010 (gmt 0)

10+ Year Member



Hi, I have a page which is failing validation.

The beta site is located here: [tinyurl.com ] and it is the home page which is failing.

The story is: I needed a way to create anchors within another anchor on the top left box. Being illegal in HTML, I found that jQuery gives me an escape route.

If you check the rudimentary jQuery routine at the bottom of the source, you will see that when the box is hovered, I strip away the outer anchor (id=devtA) before bringing the inner anchors in the popup into view. When the mouse is removed from the box, it closes the popup and replaces the outer anchor for the next mouseover to work again.

W3 validator telling me that this replacement code is invalid as I am duplicating and element id (devtA) within the jQuery script. As a point of interest, I find is strange that if the validator is unable to understand js (and why would it, it is an HTML validator), why is it reading content inside <script> tags?

Can anyone suggest a better jQuery process that will pass the validator?

daveVk

7:09 am on Sep 28, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try coding js like this (or move to external file), applies to at least to xhtml trans.

<script type="text/javascript">
/*<![cdata[*/

//js code in here

/*]]>*/
</script>

[webmasterworld.com...]

caffinated

7:19 am on Sep 28, 2010 (gmt 0)

10+ Year Member



Ha. Yeah, I just realised that, thanks DaveVK.

Actually, I noticed that this site is still in xhtml trans and it should have been html5, updated the DOCTYPE, ran it past the validator and it was fine. That's when it (head-bangingly) hit me. Just updating the rest of the site now.

I appreciate your consideration.