I am building a site using strict XHTML markup. Inside html, I need to put a js script:
<script type="text/javascript"> $(document).ready(function () { $('#nav li#nav-strona-glowna').append('<a href="/platinium/" class="hover active"><span>Strona glowna</span></a>'); </script>
Unfortunately, xhtml is no longer valid due to the "" tag inside this script. How can I check xhtml without deleting it?
You need a CDATA tag. Example stolen from this MDC page:
<script type="text/javascript"> //<![CDATA[ var i = 0; while (++i < 10) { // ... } //]]> </script>
In general, it is best to avoid the problem with JS (and CSS) in external files.
Try:
<script type="text/javascript"> <![CDATA[ $(document).ready(function () { $('#nav li#nav-strona-glowna').append('<a href="/platinium/" class="hover active"><span>Strona glowna</span></a>'); ]]> </script>
CDATA
<script> //<![CDATA[ // js goes here - bypasses browser HTML parser //]]> </script>
HTML , HTML JavaScript. - , , , .
, , CDATA JavaScript HTML.
, , HTML Strict.
, , . ?
XHTML, JavaScript . CDATA script:
<script type="text/javascript"> //<![CDATA[ $(document).ready(function () { $('#nav li#nav-strona-glowna').append('<a href="/platinium/" class="hover active"><span>Strona glowna</span></a>'); }); //]]> </script>
, JavaScript , IE, XHTML XML. . https://developer.mozilla.org/en/properly_using_css_and_javascript_in_xhtml_documents
<script type="text/javascript"><![CDATA[ // your code ]]></script>
.
? , , .
Btw. XHTML - ,
(http://xhtml.com/en/xhtml/serving-xhtml-as-xml/)
, , HTML4 HTML5, .
Source: https://habr.com/ru/post/1787966/More articles:How can I query the AppEngine database by comparing two properties of the same object? - google-app-engineHow to stack all items in a Magento basket? - phpСписок FirstOrDefault() Плохая производительность - возможен ли в этом случае словарь? - performanceWant to call a PHP page when you click div? - javascriptInitializing a C-style structure from an initialization list in C ++ - c ++Understanding the regex for a range of numbers - c #TSQL Group - more than two columns - sqlIs it possible to make JFrame always on top of applications. Does OpenGL and DirectX work? - javaGeneric Beginner Question - genericsIs there a plugin tree application for Django with a good admin? - djangoAll Articles