Solution to append failure caused by jquery selector in ie7 _ jquery

Source: Internet
Author: User
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 + ='
  
  '; PageContent + =' 
  
Product NO. Product Name Supplier ID Product Category No. Unit Price
'; $ (' # 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.
Related Article

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.