简体   繁体   English

为什么验证器不喜欢我的jquery?

[英]Why doesn't validator doesn't like my jquery?

I was just doing some validation and got some errors due to my javascript... 我只是在做一些验证,但由于我的JavaScript出现了一些错误...

Error: document type does not allow element "strong" here

$('#myobject').html('<strong>'+multiplier+'</strong><small>&nbsp;objects</small>');

It seems fairly straight forward... i'm putting some html in a html function but w3c doesn't like it... Is there a doctype more suited to this? 似乎相当简单...我在html函数中放入了一些html,但是w3c不喜欢它...是否有更适合于此的doctype?

is it the actual (pre-javascript evaluation) source that is getting the validation error? 是实际的(JavaScript之前的评估)来源是否收到验证错误?

Try marking the script contents as CDATA, ie 尝试将脚本内容标记为CDATA,即

<script type="text/javascript">/*<![CDATA[ */
$('#myobject').html('<strong>'+multiplier+'</strong><small>&nbsp;objects</small>');
/* ]]> */
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM