This article mainly introduces how to solve the append failure caused by jquery's selector in ie7.
The code is as follows:
2. I use jquery to dynamically fill in the content code in tbody as follows:
The code is as follows:
$ ("# Pending table tbody"). empty (). append (th). append (html );
This code may be problematic in ie 7 or earlier versions. jquery cannot find the correct dom location through # pending table tbody and append the content. The modified code is as follows:
The code is as follows:
$ ("Table tbody"). empty (). append (th). append (html );
Remove # pending and use table tbody to find the dom.
3. I was wondering why cascading selectors are common in ie7. Is it because jquery's bug or the html writing of nested table tbody in p is not standard enough?
I will continue to add the following:
Notes for jquery append in IE
$ (Document ). ready (function () {$. ajax ({url: 'cutepage.htm', dataType: 'json', data: 'Type = Init & PageSize = '+ EachPage +' & PageIndex = 1', success: function (msg) {// cannot be displayed under IE7, and there is no problem under Firefox ..... $ ('# Content'). append ('Product No.Product NameSupplier IDProduct category No.Unit Price') ;}, Error: function (x) {alert ("Server error code:" + x. status); $ ('# Loading '). hide ();}});});
Modify (as follows ):
$ (Document ). ready (function () {$. ajax ({url: 'cutepage.htm', dataType: 'json', data: 'Type = Init & PageSize = '+ EachPage +' & PageIndex = 1', success: function (msg) {// after modification... (There is no problem. we can see that Jquery is sensitive to html tags. pay attention to it later ........) var pageContent = ''; pageContent + ='
'; PageContent + ='
Product No. |
Product Name |
Supplier ID |
Product category No. |
Unit Price |
'; PageContent + ='
'; $ (' # Content '). append (pageContent) ;}, error: function (x) {alert ("Server error code:" + x. status); $ ('# Loading '). hide ();}});});
That is, copy the content to a parameter and do not directly use html content.
JQuery's append method does not support connection and other HTML attributes.
Very depressing. I am writing a program today and want to append some html in the document object, such
There is no problem at all, but we have encountered HTML with links such:
The code is as follows:
$ ("# Test"). append ("test ");
There is no problem in firefox. IE6 and IE7 will not be able to live or die until IE8. they only display text content without any connection. After preparing for Google, I found that Google .com could not be logged on. The basic previous pages found on Google .cn were all junk articles from the collection site, which was very depressing. After half a day, I found an article about jQuery's append function. this function carries statements similar to HTML parsing and analysis. The basic html function is okay, jQuery does not recognize links, closed tags, or custom tags. I don't know if this is true. the js Library at hand is a compressed version. it's too late to go back to the source code. Directly Create an element of the tag and insert it into it:
The code is as follows:
$ (Document. createElement ('A ')). attr ({"href": "#", "id": '# mylink '}). appendTo ("# test ");
Add the following content to the link:
The code is as follows:
$ ('# Mylink'). text ("test ");
Ah, tired. No matter what you do, go to bed and check out how jQuery's source code is written tomorrow.