开发者

Why doesn't validator doesn't like my jquery?

开发者 https://www.devze.com 2022-12-21 13:17 出处:网络
I was just doing some validation and got some errors due to my javascript... Error: document type does not allow element \"strong\" here

I was just doing some validation and got some errors due to my javascript...

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

$('#myobject').html('<st开发者_StackOverflow中文版rong>'+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?


is it the actual (pre-javascript evaluation) source that is getting the validation error?

Try marking the script contents as CDATA, i.e.

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

精彩评论

暂无评论...
验证码 换一张
取 消