---
title: "jquery在ie7下选择器的问题导致append失效"
author: "sdywcd"
date: "2014-02-19T12:38:09Z"
tags: []
categories: ["Web前端"]
slug: "jquery-ie7-append"
draft: false
lastmod: "2014-02-19T12:39:03Z"
id: 2019267
url: "https://sdywcd.iteye.com/blog/2019267"
---

1，有如下这样一段html

```
<div class="right" id="pending"> 
     
      <table  class="one" width="100%" border="0" cellspacing="0" cellpadding="0"> 
      <tbody>


     </tbody>
      </table> 
      <div id="pendingpage" class="paging"> 

      </div> 
     </div> 
```

 2，我用jquery动态填充tbody下的内容代码如下

```
$("#pending table  tbody").empty().append(th).append(html);
```

 这段代码在ie7及以下ie版本会有问题，jquery无法通过#pending table tbody 找到正确的dom位置并append内容。需要修改，修改的代码如下

```
$("table  tbody").empty().append(th).append(html);
```

 把#pending去掉 直接通过table tbody找dom

 

3，我一时很疑惑，级联的选择器很常见，但是在ie7下为什么有这种问题，难道是jquery的bug或者div下嵌套table tbody的html写法不够标准？