innerHTML and jquery in the HTML () difference Introduction _jquery

Source: Internet
Author: User

Look at an example:

Copy Code code as follows:

var tbody=document.createelement (' tbody ');
The InnerHTML of Tbody.innerhtml= ' <tr><td>ie under Tbody is read-only </td></tr> '; Wrong error in IE, target object


Now try the HTML in jquery,
Copy Code code as follows:

$ (tbody). html (' <tr><td>ie tbody innerHTML is read-only </td></tr> ');

The discovery of IE with jquery can be correctly displayed, there is no problem.
Later access to information to know that the original IE under TBODY, tr these innerhtml are read-only, not allowed to write, and in other browsers are no problem.

And jquery is used Try,catch to detect, if the error is in the catch to recall This.empty (). Append (value), is to add a string by append.

how jquery uses innerHTML

$ ("#responsediv") is a jquery object, which Val () is not meaningful to the Value property assignment, jquery does not innerHTML this attribute, it should write $ ("#responsediv") [0].innerhtml= MSG can be obtained using innerHTML for this DOM object.

Today, on this basis, add a post-loading ad method:

The code is as follows:

<div id= "Logo_m" ></div>
<script>
function Doad (datastr,id) { 
//getid (id). InnerHTML = DATASTR; This is the original JS writing
$ ("#" +id). HTML (DATASTR);//This is jquery
writing}/
* above are
direct string writes, cannot be JS code
The following code uses the jquery append to load Google ads well, Baidu seems to be useless. After loading Baidu can be used with the function of the butler with Baidu.
*/
function doad2 (datastr,id) { 
$ ("#" +id). Append (Datastr)
;

var logo_m= ' <a href= "http://www.danhw.com/" target= "_blank" ></a> ';
Doad (logo_m, ' logo_m ');
</script>

Baidu Butler brought the code after the load ad, based on jquery

<div id= "TONGLANBD" ></div>
<script type= "Text/javascript" >
$.getscript ("http:// Cbjs.baidu.com/js/m.js ", function () {
Baidu_clb_fillslotasync (" Ad ID, cannot take U "," TONGLANBD ");
});
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.