找到你要的答案

Q:Remove all text in each before this

Q:在此之前删除所有文本

i want to remove all text in this table before the " - " symbol

<table><tbody><tr>
<td id="division00" colspan="9"><h3>North Conference - SIDE BY EACH DIVISION</h3></td>
<td id="division01" colspan="9"><h3>South Conference - New Beige Division</h3></td>
<td id="division02" colspan="9"><h3>West Conference - BALL BAG DIVISION</h3></td>
</tr></tbody></table>

so new html would look like this

<table><tbody><tr>
<td id="division00" colspan="9"><h3>SIDE BY EACH DIVISION</h3></td>
<td id="division01" colspan="9"><h3>New Beige Division</h3></td>
<td id="division02" colspan="9"><h3>BALL BAG DIVISION</h3></td>
</tr></tbody></table>

我想在“-”符号之前删除此表中的所有文本

<table><tbody><tr>
<td id="division00" colspan="9"><h3>North Conference - SIDE BY EACH DIVISION</h3></td>
<td id="division01" colspan="9"><h3>South Conference - New Beige Division</h3></td>
<td id="division02" colspan="9"><h3>West Conference - BALL BAG DIVISION</h3></td>
</tr></tbody></table>

所以新的HTML看起来像这样

<table><tbody><tr>
<td id="division00" colspan="9"><h3>SIDE BY EACH DIVISION</h3></td>
<td id="division01" colspan="9"><h3>New Beige Division</h3></td>
<td id="division02" colspan="9"><h3>BALL BAG DIVISION</h3></td>
</tr></tbody></table>
answer1: 回答1:
jQuery('td h3').each(function() {
   var current_text = jQuery(this).html(),
       exploded_text = current_text.split('-'),
       last_part = exploded_text.pop();

   jQuery(this).html(last_part.trim());

});

please note that I'm making a few assumptions about the lack of classnames and selector hierarchy.

jQuery('td h3').each(function() {
   var current_text = jQuery(this).html(),
       exploded_text = current_text.split('-'),
       last_part = exploded_text.pop();

   jQuery(this).html(last_part.trim());

});

请注意,我做了一些假设缺乏的类名称和选择层次。

jquery