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>