How to get this jQuery string to validate as strict XHTML

I have this jQuery bit at the top of my page (used for a simple image carousel):

$(document).ready(function(){   
    $("#slider").easySlider({
        prevText:'<div id="backarrow">Back</div>',
        nextText:'<div id="nextarrow">View Other Projects</div>',
        orientation:'horizontal'
    });
});

however, I cannot get it to check the strict XHTML line:

Row 12, column 33: document type don't let the div element here

Any ideas?

+3
source share
2 answers
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready(function(){   
    $("#slider").easySlider({
            prevText:'<div id="backarrow">Back</div>',
            nextText:'<div id="nextarrow">View Other Projects</div>',
            orientation:'horizontal'
    });
});
/* ]]> */
</script>

This tells the validator to interpret the script as character data, not markup, and thus it will not analyze the structure of the CDATA block. Wikipedia has additional information .

+12
source

JQuery. JS (CDATA, ceejayoz ).

-1

Source: https://habr.com/ru/post/1709147/


All Articles