简体   繁体   中英

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...

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. 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. It's used when you get data from XML to recognize that it is the HTML content

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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