最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Remove div and table from td element using jquery - Stack Overflow

programmeradmin0浏览0评论

I have a file named 'ahblog.htm' and inside this file contains a 'td element'. I am using 'jquery' to extract the 'td element' ( content topContent topContentBox) and put it into a 'div'. The problem I am having is removing a 'div' and 'table' from inside the 'td element'.

below is my php code

<?php 
include( 'site/simple_html_dom.php'); 
$html=file_get_html( '/');
$html->save('site/ahblog.htm')                      
?>
<script type="text/javascript" src="site/jquery.js"></script>
<script type="text/javascript">
$('document').ready(function() {
$('#wrap').click(function (event)
{
event.preventDefault();
});
$('#wrap').load('site/ahblog.htm .content.topContent.topContentBox');
});
</script>

below is the 'td element'

<div id="wrap">
<td class="content topContent topContentBox" height="100%" width="100%" valign="top">
<div class="titleLine"> <----- I want to remove this one
<div style id="streamDivLeveljournal43125372">
<div style id="streamDivLeveljournal100703120097">
<div style id="streamDivLeveljournal823117600">
<div style id="streamDivLeveljournal43115856">
<div style id="streamDivLeveljournal100703110797">
<table width="100%">...</table> <----- I want to remove this one
</td>
</div>

The problem I am having is removing the table as there are multiple tables, and because it doesn't have an 'ID'. If any one coud help me I will really appreciate it.

I have a file named 'ahblog.htm' and inside this file contains a 'td element'. I am using 'jquery' to extract the 'td element' ( content topContent topContentBox) and put it into a 'div'. The problem I am having is removing a 'div' and 'table' from inside the 'td element'.

below is my php code

<?php 
include( 'site/simple_html_dom.php'); 
$html=file_get_html( 'http://achievementhunter./blog/');
$html->save('site/ahblog.htm')                      
?>
<script type="text/javascript" src="site/jquery.js"></script>
<script type="text/javascript">
$('document').ready(function() {
$('#wrap').click(function (event)
{
event.preventDefault();
});
$('#wrap').load('site/ahblog.htm .content.topContent.topContentBox');
});
</script>

below is the 'td element'

<div id="wrap">
<td class="content topContent topContentBox" height="100%" width="100%" valign="top">
<div class="titleLine"> <----- I want to remove this one
<div style id="streamDivLeveljournal43125372">
<div style id="streamDivLeveljournal100703120097">
<div style id="streamDivLeveljournal823117600">
<div style id="streamDivLeveljournal43115856">
<div style id="streamDivLeveljournal100703110797">
<table width="100%">...</table> <----- I want to remove this one
</td>
</div>

The problem I am having is removing the table as there are multiple tables, and because it doesn't have an 'ID'. If any one coud help me I will really appreciate it.

Share asked Dec 17, 2013 at 17:16 AstonAston 1991 gold badge3 silver badges18 bronze badges 2
  • Why don't you add an ID? – Dan Grahn Commented Dec 17, 2013 at 17:17
  • Why don't you add an id ? Try $(#wrap table) – Ricardo Lohmann Commented Dec 17, 2013 at 17:17
Add a ment  | 

2 Answers 2

Reset to default 3
$(".content.topContent.topContentBox").find(".titleLine, table").remove(); 

Should do it.

try this:

$('#wrap td').find('.titleLine').remove();
$('#wrap td').find('table').remove();
发布评论

评论列表(0)

  1. 暂无评论