Christopher
Christopher

Reputation: 620

jQuery plugin doesn't pass HTML validation

I have this:

<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('#menu-main-menu li a').after('<p class="separator">/</p>');
        jQuery(".textwidget a[href^='http://']").attr("target","_blank");
    }); 
</script>

And can't pass HTML validation with the error:

document type does not allow element "p" here

The snippet is placed at the bottom in the footer file of my WordPress platform.

Any suggestions, please? It's obviously is my paragraph tags. The css for .separator is just a display: inline; thing I use as a separator for my menu.

Upvotes: 0

Views: 86

Answers (1)

nd.
nd.

Reputation: 8932

The validator should be happy with a CDATA section around your script:

<script type="text/javascript"><![CDATA[
jQuery(document).ready(function(){
  jQuery('#menu-main-menu li a').after('<p class="separator">/</p>');
  jQuery(".textwidget a[href^='http://']").attr("target","_blank");
});
]]></script>

Upvotes: 2

Related Questions