Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
dear friends!
i have alternate empty tds in a tr ,want to remove their complete markup from td,are like
HTML
<table><tbody><tr class="EffectiveRow">
<td class="GridItemStyle" style="width:30px;text-align:center;">
<table><tbody><tr><td class="ExtraPadding" style="width:48px;text-align:center;">748</td></tr></tbody></table>
<table><tbody><tr><table><tbody><tr><table><tbody><tr><table><tbody><tr><table><tbody><tr><td class="GridItemStyle" style="width:0px;"></td></tr></tbody></table></tr></tbody></table></tr></tbody></table></tr></tbody></table></tr></tbody></table>
<table><tbody><tr><td class="GridItemStyle" style="width:98px;text-align:center;">Better Homes LLC</td></tr></tbody></table>
<table><tbody><tr><table><tbody><tr><table><tbody><tr><table><tbody><tr><table><tbody><tr><td class="GridItemStyle" style="width:0px;"></td></tr></tbody></table></tr></tbody></table></tr></tbody></table></tr></tbody></table></tr></tbody></table>
<table><tbody><tr><td class="GridItemStyle" style="width:50px;text-align:center;">4.2</td></tr></tbody></table>
<table><tbody><tr><table><tbody><tr><table><tbody><tr><table><tbody><tr><table><tbody><tr><td class="GridItemStyle" style="width:0px;"></td></tr></tbody></table></tr></tbody></table></tr></tbody></table></tr></tbody></table></tr></tbody></table>
<table><tbody><tr><td class="GridItemStyle" style="width:142px;text-align:center;">Map icon on unit detail page</td></tr></tbody></table>
<table><tbody><tr><table><tbody><tr><table><tbody><tr><table><tbody><tr><table><tbody><tr><td class="GridItemStyle" style="width:0px;"></td></tr></tbody></table></tr></tbody></table></tr></tbody></table></tr></tbody></table></tr></tbody></table>
</td></tr></tbody></table>

want to go for any jquery approach,some body help me to do so
JavaScript
$(".EffectiveRow").html().replace('<table><tbody><tr><table><tbody><tr><table><tbody><tr><table><tbody><tr><table><tbody><tr><td class="GridItemStyle" style="width:0px;"></td></tr></tbody></table></tr></tbody></table></tr></tbody></table></tr></tbody></table></tr></tbody></table>','');

thanks in advance
Posted
Updated 29-Jun-14 3:50am
v2
Comments
Kornfeld Eliyahu Peter 29-Jun-14 9:50am    
Your HTML table not valid at all! Please fix it first...
Sergey Alexandrovich Kryukov 29-Jun-14 21:49pm    
I checked up: this is formally valid both XML (well-formed) and HTML, even though it make no practical sense...
—SA
Kornfeld Eliyahu Peter 30-Jun-14 1:03am    
It may be a valid XML, but definitely not a valid HTML. TR elements can only contain TH or TD elements according to standard HTML...
Sergey Alexandrovich Kryukov 30-Jun-14 11:32am    
Of course. And I can see those invalid TR now, thank you. This HTML is still rendered, but browser tend to render invalid HTMLs; everything should be validated as XHTML. You are right: this non-HTML should be fixed first.

Thank you.
—SA
Kornfeld Eliyahu Peter 30-Jun-14 13:13pm    
It's hard to see that in the mess OP has here :-)

1 solution

If it made any sense (which I double, please see my comment to the question), I would advise to use, instead of stuctureless replace, direct DOM manipulations: http://api.jquery.com/category/manipulation/dom-removal[^].

[EDIT]

As Kornfeld Eliyahu Peter correctly pointed out, your HTML is absolutely invalid, so first, you need to address it: how did you get that invalid HTML in first place? When I say "if it made any sense", I meant that your request does no seem to make any practical sense.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900