The jQuery HTML of method does not address the problem of not being able to display content

  • 2020-03-30 03:39:05
  • OfStack

$("#content").html(data.content); 
$("#content")[0].innerHTML = data.content;

Today, I came across the HTML method in jquery and I couldn't use it. I had to use the innerHTML to show the content. I have not found the specific reason, which must be related to the content. The HTML that cannot be displayed will be put up for future inspection. The reason is that I received an email from CSDN.


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 

<title> Intelligent hardware weekly  -  The first 4 period </title> 
<style type="text/css"> 
a:link { 
color: #333; 
text-decoration: none; 
} 

a:hover { 
color: #c00; 
} 

span.hot { 
font-weight: bold; 
} 

.button * { 
vertical-align: middle; 
} 
</style></head> 

<body> 
<div> 
<table align="center" border="0" cellpadding="0" cellspacing="0" width="760"> 
<tbody> 
<tr> 
<td width="540"><a href="http://newsletter.csdn.net/m/news/newsletter/index/13" rel="external nofollow" rel="external nofollow" rel="external nofollow" target="_blank"><img style="cursor: pointer;border: 0px;" alt="" src="http://cms.csdnimg.cn/article/201406/12/539917aecc84c.jpg"></a></td> 
<td width="30"></td> 
<td width="190" style="font-size: 12px; font-family: Microsoft Yahei; line-height: 40px; padding-right: 3px" align="right">2014-07-29  The first  
<span style="color: #c00; text-decoration: none;">4</span> period </td> 
</tr> 
<tr> 
<td colspan="3" bgcolor="#cc0000" height="5"></td> 
</tr> 
<tr> 
<td width="540" valign="top"> 
<!--  Express delivery of information  --> 
<h1 style="font-family: Microsoft Yahei; font-size: 20px; margin: 20px 0 0 0; font-weight: normal; border-bottom: solid 1px #d1d1d1; color: #c00; padding-bottom: 5px"><img style="margin-right: 5px" alt="" src="http://articles.csdn.net/uploads/allimg/120413/118_120413113016_1.gif"> Express delivery of information  
</h1> 
<dl style="padding: 6 0 0 0;margin:0px;clear: both;"> 
<!--  Determine if the picture exists  --> 
<img src="http://newsletter.csdn.net/uploadfile/logoimg/image/20140729/20140729111725_67948_logo.jpg" border="0" style="float:left;padding: 15px 10px 15px 0;width: 160px;height: 110px;"> 
<dt style="color: #333; font-size: 16px; font-family: Microsoft Yahei; margin: 10px 0 3px 0; line-height: 26px;"> 
<a style="text-align: left; color: #333; font-size: 16px; font-weight: bold; text-decoration: none" href="http://www.csdn.net/article/2014-07-28/2820881" rel="external nofollow" rel="external nofollow" target="_blank"> 
<span class="hot"> Is it too early to build a platform for intelligent hardware ecology? </span></a> 
</dt> 
<dd style="color: #666666; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin: 0px;"> 
 At present, the development of intelligent hardware industry is explored by start-ups, and the giants follow up to build open platforms. However, the lack of benchmarking products, unclear prospects for developers and applications, and the lack of "pain points" for users in the smart hardware market indicate that the market is still in its infancy and it is still too early to build a platform. <a href="http://www.csdn.net/article/2014-07-28/2820881" rel="external nofollow" rel="external nofollow" target="_blank" style="color: #c00; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin-left: 0px;padding-bottom:20px;">[ Read the original ] </a> 
</dd> 
</dl> 
<dl style="padding: 6 0 0 0;margin:0px;clear: both;"> 
<!--  Determine if the picture exists  --> 
<dt style="color: #333; font-size: 16px; font-family: Microsoft Yahei; margin: 10px 0 3px 0; line-height: 26px;"> 
<a style="text-align: left; color: #333; font-size: 16px; font-weight: bold; text-decoration: none" href="http://download.csdn.net/detail/zhaifangqing/7604351" rel="external nofollow" rel="external nofollow" target="_blank"> 
<span class="hot"> Dry goods sharing 2014 shenzhen Maker Faire "Makers and business" forum speech PDF</span></a> 
</dt> 
<dd style="color: #666666; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin: 0px;"> 
2014 years 4 month 6 solstice 7 Day, held in shenzhen Featured level Maker Faire . In the makers and business forum, Atmel COO Time of roll call CEO Electronic new me CEO , Seeed The founder, HAXLR8R Founder and former foxconn CEO And others, from Maker From the perspectives of culture, crowdfunding, incubation, entrepreneurship and productization, we share our observations and experiences, and summarize our stories and experiences. <a href="http://download.csdn.net/detail/zhaifangqing/7604351" rel="external nofollow" rel="external nofollow" target="_blank" style="color: #c00; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin-left: 0px;padding-bottom:20px;">[ Read the original ] </a> 
</dd> 
</dl> 
<dl style="padding: 6 0 0 0;margin:0px;clear: both;"> 
<!--  Determine if the picture exists  --> 
<dt style="color: #333; font-size: 16px; font-family: Microsoft Yahei; margin: 10px 0 3px 0; line-height: 26px;"> 
<a style="text-align: left; color: #333; font-size: 16px; font-weight: bold; text-decoration: none" href="http://www.csdn.net/article/2014-07-16/2820690-10-best-AR-App" rel="external nofollow" rel="external nofollow" target="_blank"> 
<span class="hot"> Augmented reality: 10 big AR Apps peek into the mobile future </span></a> 
</dt> 
<dd style="color: #666666; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin: 0px;"> 
 Improvements in smartphone performance, and wearables in particular Google Glass let AR Technology is heating up again, and we've seen a lot of it this year AR New applications for technology development. This article recommended 10 good AR Applications, many of which are developers from traditional industries. <a href="http://www.csdn.net/article/2014-07-16/2820690-10-best-AR-App" rel="external nofollow" rel="external nofollow" target="_blank" style="color: #c00; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin-left: 0px;padding-bottom:20px;">[ Read the original ] </a> 
</dd> 
</dl> 
<dl style="padding: 6 0 0 0;margin:0px;clear: both;"> 
<!--  Determine if the picture exists  --> 
<dt style="color: #333; font-size: 16px; font-family: Microsoft Yahei; margin: 10px 0 3px 0; line-height: 26px;"> 
<a style="text-align: left; color: #333; font-size: 16px; font-weight: bold; text-decoration: none" href="http://www.csdn.net/article/2014-07-24/2820848-lenovo-3-hardware" rel="external nofollow" rel="external nofollow" target="_blank"> 
<span class="hot"> The Internet of things has a "new bench"   Lenovo introduces three smart hardware </span></a> 
</dt> 
<dd style="color: #666666; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin: 0px;"> 
 Lenovo launched "China's most reliable Internet business platform" NBD(New BusinessDevelopment , nicknamed "new bench" ) . At the same time, it released the first three innovative products "incubated" by the platform: smart glasses, smart air purifiers and smart routers. <a href="http://www.csdn.net/article/2014-07-24/2820848-lenovo-3-hardware" rel="external nofollow" rel="external nofollow" target="_blank" style="color: #c00; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin-left: 0px;padding-bottom:20px;">[ Read the original ] </a> 
</dd> 
</dl> 

<!--  New product  --> 
<h1 style="font-family: Microsoft Yahei; font-size: 20px; margin: 20px 0 0 0; font-weight: normal; border-bottom: solid 1px #d1d1d1; color: #c00; padding-bottom: 5px"><img style="margin-right: 5px" alt="" src="http://articles.csdn.net/uploads/allimg/120413/118_120413113016_1.gif"> New product  
</h1> 
<dl style="padding: 6 0 0 0;margin:0px;clear: both;"> 
<!--  Determine if the picture exists  --> 
<img src="http://newsletter.csdn.net/uploadfile/logoimg/image/20140729/20140729103841_55898_logo.jpg" border="0" style="float:left;padding: 15px 10px 15px 0;width: 160px;height: 110px;"> 
<dt style="color: #333; font-size: 16px; font-family: Microsoft Yahei; margin: 10px 0 3px 0; line-height: 26px;"> 
<a style="text-align: left; color: #333; font-size: 16px; font-weight: bold; text-decoration: none" href="https://www.kickstarter.com/projects/1157856441/table-air?ref=category" rel="external nofollow" rel="external nofollow" target="_blank"> 
<span class="hot"> Design the most beautiful intelligent air purifier  Table Air</span></a> 
</dt> 
<dd style="color: #666666; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin-left: 0px;"> 
 It is an air purifier from shenzhen that allows users to control it from their mobile phones. It automatically detects air quality every morning. The design of the air purifier is unusual, not as stupid as the traditional equipment, the appearance is more simple. <a href="https://www.kickstarter.com/projects/1157856441/table-air?ref=category" rel="external nofollow" rel="external nofollow" target="_blank" style="color: #c00; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin-left: 0px;padding-bottom:20px;">[ Read the original ] </a> 
</dd> 
</dl> 
<dl style="padding: 6 0 0 0;margin:0px;clear: both;"> 
<!--  Determine if the picture exists  --> 
<img src="http://newsletter.csdn.net/uploadfile/logoimg/image/20140729/20140729102357_10579_logo.jpg" border="0" style="float:left;padding: 15px 10px 15px 0;width: 160px;height: 110px;"> 
<dt style="color: #333; font-size: 16px; font-family: Microsoft Yahei; margin: 10px 0 3px 0; line-height: 26px;"> 
<a style="text-align: left; color: #333; font-size: 16px; font-weight: bold; text-decoration: none" href="https://www.kickstarter.com/projects/261147844/airfy-beacon-imagination-meets-smart-home-automati?ref=category" rel="external nofollow" rel="external nofollow" target="_blank"> 
<span class="hot"> Based on the iBeacon Smart home center  airfy Beacon</span></a> 
</dt> 
<dd style="color: #666666; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin-left: 0px;"> 
 Apple released it last year iBeacon At first, the product direction it pointed out to people was more commercial, such as using in shopping malls and stores airfy Is based on the technology of household products. It can be used as a mobile phone with NEST , IFTTT , hue Smart lights and other equipment relay station, the difference is that the user only need to approach airfy "Can trigger a number of functions, such as lighting up and turning on the stereo. <a href="https://www.kickstarter.com/projects/261147844/airfy-beacon-imagination-meets-smart-home-automati?ref=category" rel="external nofollow" rel="external nofollow" target="_blank" style="color: #c00; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin-left: 0px;padding-bottom:20px;">[ Read the original ] </a> 
</dd> 
</dl> 
<dl style="padding: 6 0 0 0;margin:0px;clear: both;"> 
<!--  Determine if the picture exists  --> 
<img src="http://newsletter.csdn.net/uploadfile/logoimg/image/20140729/20140729101200_43505_logo.jpg" border="0" style="float:left;padding: 15px 10px 15px 0;width: 160px;height: 110px;"> 
<dt style="color: #333; font-size: 16px; font-family: Microsoft Yahei; margin: 10px 0 3px 0; line-height: 26px;"> 
<a style="text-align: left; color: #333; font-size: 16px; font-weight: bold; text-decoration: none" href="http://bong.cn/" rel="external nofollow" rel="external nofollow" target="_blank"> 
<span class="hot"> A smart bracelet with a one-year battery life  Bong II</span></a> 
</dt> 
<dd style="color: #666666; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin-left: 0px;"> 
bong The second band, which was released last week, will be available for sale 99 Yuan. But the most exciting thing is not the price, but the endurance for a year, which is rare in wearables today. Of course, in addition to endurance, bong In function also made new improvement and innovation. <a href="http://bong.cn/" rel="external nofollow" rel="external nofollow" target="_blank" style="color: #c00; font-size: 13px; font-family:  Song typeface ; line-height: 22px; margin-left: 0px;padding-bottom:20px;">[ Read the original ] </a> 
</dd> 
</dl> 

<!--dl style="clear: both;"> 
<dt style="color: #333; font-size: 14px; font-family: Microsoft Yahei; margin-top: 5px; line-height: 22px"> 
<img style="margin-right: 10px" alt="" src="http://articles.csdn.net/uploads/allimg/120416/118_120416163515_1.png"> 
<a href="http://club.csdn.net/module/club/cto/bbs/7468" rel="external nofollow" rel="external nofollow" style="text-align: left; color: #333; font-size: 14px; text-decoration: none" target="_blank"> By Microsoft legitimate department targeted by Microsoft legitimate department targeted ......</a> 
</dt> 
<dt style="color: #333; font-size: 14px; font-family: Microsoft Yahei; margin-top: 5px; line-height: 22px"> 
<img style="margin-right: 10px" alt="" src="http://articles.csdn.net/uploads/allimg/120416/118_120416163515_1.png"> 
<a href="http://club.csdn.net/module/club/cto/bbs/7468" rel="external nofollow" rel="external nofollow" style="text-align: left; color: #333; font-size: 14px; text-decoration: none" target="_blank"> Microsoft was targeted by the legitimate department ......</a> 
</dt> 
<dt style="color: #333; font-size: 14px; font-family: Microsoft Yahei; margin-top: 5px; line-height: 22px"> 
<img style="margin-right: 10px" alt="" src="http://articles.csdn.net/uploads/allimg/120416/118_120416163515_1.png"> 
<a href="http://club.csdn.net/module/club/cto/bbs/7464" rel="external nofollow" style="text-align: left; color: #333; font-size: 14px; text-decoration: none" target="_blank"> Lost the direction, please friends, senior guidance </a> 
</dt> 
<dt style="color: #333; font-size: 14px; font-family: Microsoft Yahei; margin-top: 5px; line-height: 22px"> 
<img style="margin-right: 10px" alt="" src="http://articles.csdn.net/uploads/allimg/120416/118_120416163515_1.png"> 
<a href="http://club.csdn.net/module/club/cto/bbs/7474" rel="external nofollow" style="text-align: left; color: #333; font-size: 14px; text-decoration: none" target="_blank"> The programmer invites you to share your thoughts on management topics </a> 
</dt> 
</dl--> 
</td> 
<td width="30"></td> 
<td width="190" valign="top"> 
<h3 style="margin: 20px 0 0 0; font-family: Microsoft Yahei;color: #c00; font-size: 16px; font-weight: normal; text-decoration: none;padding-bottom: 5px;"><a href="http://newsletter.csdn.net/m/news/newsletter/index/13" rel="external nofollow" rel="external nofollow" rel="external nofollow" target="_blank" style="margin: 20px 0 0 0; font-family: Microsoft Yahei;color: #c00; font-size: 16px; font-weight: normal; text-decoration: none;"> Smart hardware weekly </a></h3> 
<p style="line-height: 22px; font-size: 13px; margin: 5px 0 0 0;"> Smart hardware weekly is CSDN The weekly album extracts information from various aspects of the hardware field and presents the latest development technology information, hot hardware products and hardware team stories related to the Internet of things. More exciting content, welcome to visit <a href="http://hardware.csdn.net" rel="external nofollow" target="_blank" style="text-decoration: underline;color: #c00;font-size: 13px;">CSDN Intelligent hardware technology community </a> . </p> 
<!--  Recent activities  --> 

<h3 style="margin: 20px 0 0 0; font-family: Microsoft Yahei;color: #c00; font-size: 16px; font-weight: normal; text-decoration: none;padding-bottom: 5px;"> Recent activities </h3> 
<p style="line-height: 22px; font-size: 13px; margin: 5px 0 0 0;"><a style="color:#333; font-size:13px;text-decoration: underline;font-family: Microsoft Yahei;" target="_blank" href="http://huiyi.csdn.net/activity/product/goods_list?project_id=1203" rel="external nofollow" > Online training HTML5 Mobile application development: Cordova Application development </a><br> 
<span style="font-size: 12px; line-height: 22px; margin-bottom: 20px; color: #999"></span> </p> 
<!--  WeChat  --> 
<h3 style="margin: 20px 0 0 0; font-family: Microsoft Yahei;color: #c00; font-size: 16px; font-weight: normal; text-decoration: none;padding-bottom: 5px;">mobilehub WeChat </h3> 
<p style="font-size: 12px; text-align:center; font-family: Microsoft Yahei; line-height: 18px; margin-bottom: 15px; color: #999;border: 1px solid #eee;"><img alt="" style="width: 190px; height: 190px; " src="http://cms.csdnimg.cn/article/201406/11/5397f8771d247.jpg"> 
<br> Keep abreast of the latest events </p> 
<h3 style="margin: 20px 0 0 0; font-family: Microsoft Yahei;color: #c00; font-size: 16px; font-weight: normal; text-decoration: none;padding-bottom: 5px;"> Weibo: <a href="http://weibo.com/csdnmobile" rel="external nofollow" target="_blank" style="margin: 20px 0 0 0; font-family: Microsoft Yahei;color: #c00; font-size: 16px; font-weight: normal; text-decoration: none;">@csdnmobile</a></h3> 

<p style="font-size: 12px; font-family: Microsoft Yahei; line-height: 22px; margin-bottom: 20px; color: #999"> Welcome to subscribe to CSDN Other technical mail: <br> 
<a href="http://newsletter.csdn.net/m/news/newsletter/index/1" rel="external nofollow" style="margin-right: 5px; color: rgb(204, 102, 0)" target="_blank"> 
<span style="text-decoration: underline;"> The mobile weekly </span></a>|<a href="http://newsletter.csdn.net/m/news/newsletter/index/12" rel="external nofollow" style="margin-right: 10px; color: rgb(204, 102, 0)" target="_blank"> 
<span style="text-decoration: underline;"> Mobile game weekly </span></a><a href="http://newsletter.csdn.net/m/news/newsletter/index/4" rel="external nofollow" style="margin-right: 5px; color: rgb(204, 102, 0)" target="_blank"> 
<br/><span style="text-decoration: underline;"> The programmer express </span></a>|<a href="http://newsletter.csdn.net/m/news/newsletter/index/2" rel="external nofollow" style="margin-left: 5px; color: rgb(204, 102, 0)" target="_blank"> 
<span style="text-decoration: underline;"> Cloud weekly </span></a></p> 
</td> 
</tr> 
<tr> 
<td colspan="2" height="10"></td> 
</tr> 
<tr> 
<td colspan="3" align="center" bgcolor="#ebebeb" style="font-size: 12px; line-height: 20px; padding: 10px 15px; color: rgb(102, 102, 102)"> 
 To view <a style="color: rgb(204, 102, 0)" target="_blank" href="http://newsletter.csdn.net/m/news/newsletter/index/13" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><span style="text-decoration: underline"> Intelligent hardware weekly review </span></a> , more exciting content <a style="color: rgb(204, 102, 0)" href="http://mobile.csdn.net/" rel="external nofollow" target="_blank"><span style="text-decoration: underline;">CSDN Mobile channel </span></a> . Welcome to recommend to your friends <a style="color: rgb(204, 102, 0)" href="http://mailfeed.csdn.net/es.ashx?cid=49&email=a@qq.com&op=w" rel="external nofollow" target="_blank"><span style="text-decoration: underline;"> To subscribe to </span></a> This mailing list. <br> If you don't want to receive it again, you can <a style="color: rgb(204, 102, 0)" href="http://mailfeed.csdn.net/es.ashx?cid=49&email=a@qq.com&op=b" rel="external nofollow" target="_blank"><span style="text-decoration: underline;"> unsubscribe </span></a></td> 
</tr> 
</tbody> 
</table> 
<div style="display:none;"><script src="http://s20.cnzz.com/stat.php?id=5217866&web_id=5217866" language="JavaScript"></script></div> 
</div> 
<img src="http://tracker.csdn.net/edmtracker.aspx?e=%25EMAIL%25&m=3060" width="1" height="1"> 
<div style="display:none;"><script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_5752922'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s17.cnzz.com/stat.php%3Fid%3D5752922%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));</script></div></body> 
</html> 
<img src="http://tracker.csdn.net/edmtracker.aspx?e=a@qq.com&m=4459" width=1 height=1>

Here's what others have to add:

JQuery in general is still very good, but sometimes it will have some problems, such as jQuery's HTML () method set HTML code, in one case, ie6, ie7, ie8 is not set HTML code. The problem described in this article is only for browsers below ie8 (including ie8).

1. Under what circumstances IE6, IE7, IE8 jQuery. HTML (" XXX ") method will not set the HTML code?

A: when the loaded HTML code inside the following situation, ie8 (including ie8) the following is not set on the HTML code:

A) the set HTML code contains references to other js, such as: < Script SRC = "Stone. Js" type = "text/javascript" > < / script> In this case, setting the HTML code is invalid.
Function Stone(){alert(" my name is MT"); }, setting the HTML code invalid.
C) the set HTML code has CSS style, such as:.stone ul li{list-style:none; Float: left; }, etc., the set HTML code is invalid. Additional: HTML code to be set if contains references to other external

Style, e.g. : < The link href = ".. / Css/style.css. Css "rel =" stylesheet "type =" text/Css "/ > , while not affecting the HTML Settings, the referenced CSS is invalid and has no style. ]

2. Reason analysis:

A: the HTML that is set up, jQuery simply parses it into HTML and doesn't care about the other factors and code that cause the above problems.

3. Solutions:

A: remove the set of js references CSS references and code can be resolved.

Thank you for your cooperation. Contact QQ: 1370569.


Related articles: