简体   繁体   English

使用CDATA是否正确替换

[英]Is the use of CDATA correct to replace <

Am I using the CDATA correctly in code below because I am getting no error but getting warnings on start tag < starting here... 我是否在下面的代码中正确使用了CDATA,因为我没有收到任何错误,但收到了关于开始标记<从此处开始的警告...

var $tbody = $('#qandatbl_onthefly > tbody');
var $tr = $("<![CDATA[<tr class='optionAndAnswer' align='center'>]]");
var $qid = $("<![CDATA[<td width='5%' class='qid'></td>]]").text(qnum);
var $options = $("<![CDATA[<td><table class='option'><tbody><tr><td class='opt'>1. Option Type:</td></tr></tbody></table></td>]]");
var $video = $("<![CDATA[<td width='17%' class='video'></td>]]");
var $endtr = $("<![CDATA[</tr>]]");
var $questionType = '';

You probably don't need the CDATA sections, but the ones you have are incomplete. 您可能不需要CDATA部分,但是其中的部分是不完整的。 The end is missing an additional >: 末尾缺少一个额外的>:

<![CDATA[ ... ]]>

<![CDATA[ <div>...</div> ]]>

The trailing angle bracket is missing in the examples you provided. 您提供的示例中缺少尾随尖括号。

I think you dont need to use CDATA here. 我认为您不需要在这里使用CDATA It's used when you get data from XML to recognize that it is the HTML content 当您从XML获取数据以识别它是HTML内容时使用

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

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