2013-12-12 146 views
2

我有一個div其中包含一個td class='small'我想用jQuery來刪除它。使用jquery刪除td類

<td class="small" style="padding:8px 0;color:#999;vertical-align:middle;"> 
A bunch of gibberish... 
</td> 

在我主要的代碼,我使用jQuery來提取一個文件一個div然後替換div與提取的主代碼。

<head> 
<meta http-equiv="content-type" content="text/html;charset=UTF-8"> 
<meta http-equiv="content-language" content="en"> 
<meta name="viewport" content="width=500" /> 
<title>Rooster Teeth News</title> 
<link rel="stylesheet" type="text/css" href="site/wwwRand1.css"> 
<?php 
include('site/simple_html_dom.php'); 
$html=file_get_html('http://roosterteeth.com/home.php'); 
$html->save('site/result.htm')      
?> 
<script type="text/javascript" src="site/jquery.js"></script> 
<script type="text/javascript"> 
$('document').ready(function() {  
$('#postsArea').load('site/result.htm #postsArea'); 
}); 
</script> 
</head> 
<body> 
<div id="wrap"> 
<div id="postsArea"></div> 
</div> 

我遇到的問題是我只能在'div'被替換後刪除'td'。如果有人可以幫助我,我會非常感激。謝謝。

+0

$( 'td.small')removeClass( '小'); –

+0

如果元素是新的ajax內容的一部分,則需要使用'load()'的回調...請參閱文檔 – charlietfl

+0

感謝您的幫助 – Sabre

回答

3

load()方法有一個回調函數,所以你可以使用:

$('#postsArea').load('site/result.htm', function(){ 
    $('#postsArea td.small').removeClass('small') 
}); 
+0

爲什麼downvote?我確實有一些錯別字......但現在修好了。 – Sergio

+0

非常感謝您的幫助 – Sabre

+0

@Sabre,很高興我能幫到您! – Sergio