


Solution to the problem of jquery's selector under ie7 that causes append to fail_jquery
1, there is a piece of html as follows
2. I use jquery to dynamically fill in the content under tbody. The code is as follows
$("#pending table tbody").empty().append(th).append(html);
This code will have problems in ie7 and below ie versions. jquery cannot find the correct dom position and append the content through #pending table tbody. It needs to be modified. The modified code is as follows
$("table tbody").empty().append(th).append(html);
Remove #pending and find dom directly through table tbody
3. I was confused for a while. Cascading selectors are very common, but why is there such a problem under IE7? Is it a jquery bug or the HTML writing method of nested table tbody under div is not standard enough?
Let me continue to add:
Things to note when using jquery append in IE
$(document).ready(function() { $.ajax({ url: 'Cutepage.htm', dataType: 'json', data: 'type=Init&PageSize=' + EachPage + '&PageIndex=1', success: function(msg) { //在IE7下无法显示,在火狐下没有问题。。。。。 $('#Content').append('<tr><td width="19%"> 商品编号</td><td width="15%">商品名字</td><td width="20%">供应商商编号</td><td width="30%">商品种类编号</td><td width="10%">单价</td></tr>'); }, error: function(x) { alert("服务器错误代码:" + x.status); $('#Loading').hide(); } }); });
Modification (below):
$(document).ready(function() { $.ajax({ url: 'Cutepage.htm', dataType: 'json', data: 'type=Init&PageSize=' + EachPage + '&PageIndex=1', success: function(msg) { //修改后...(这样就没有问题了,可以看出Jquery对html标签是比较敏感的,以后需要注意........) var pageContent = ''; pageContent += '<table border="2">'; pageContent += '<tr><td width="19%"> 商品编号</td><td width="15%">商品名字</td><td width="20%">供应商商编号</td><td width="30%">商品种类编号</td><td width="10%">单价</td></tr>'; pageContent += '</table>'; $('#Content').append(pageContent ); }, error: function(x) { alert("服务器错误代码:" + x.status); $('#Loading').hide(); } }); });
Copy the content to a parameter, do not use html content directly.
jQuery’s append method does not support HTML attributes such as connections
I was very depressed. I was writing a program today and wanted to append some HTML to the document object, such as
. These were no problem at all, but I encountered HTML with links such as:
There is no problem with firefox, but IE6, IE7 and IE8 are stuck, and only text content is displayed without any connections. I was preparing to Google, but I found that I could no longer log in to Google.com. Basically, the page I found on Google.cn was full of junk articles from collection sites, which was very depressing. After working on it for a long time, I found an article that said it was a problem with jQuery's own append function. This function has its own statements similar to HTML parsing and analysis. Basic HTML is fine, but it encounters links or tags that are not completely closed or are customized. Tags, jQuery just can't recognize them. I don’t know if this is really the case. The js library I have is a compressed version. It’s too late and my head is dizzy and I don’t want to look at the source code of Laoshizi anymore. Just create an element of the a tag and insert it directly, like this:
$(document.createElement(‘a’)).attr({"href":"#", "id": '#mylink'}).appendTo("#test");
Then attach content to this link:
$(‘#mylink’).text("test");
Hey, are you tired? No matter, I'm going to bed. If I have time tomorrow, let's take a look at how the source code of jQuery is written.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.
