I need help with the following using javascript or jQuery.
I need to perform the following operations on a string like the below. There are multiple like this on the page and the main identifier is “ms-gb” class on the td tag.
<tbody id=“titl4909-1_” groupString=“%3B%23BOE%204%2E0%20Shop%20Cost%20Study%3B%23”><tr id=“group0”><td colspan=“100” nowrap class=“ms-gb”><a href=“javascript:” onclick=“javascript:ExpCollGroup(‘4909-1_’, ‘img_4909-1_’,event, false);return false;”><img src=“/layouts/images/minus.gif" border=“0” alt=“collapse” id="img_4909-1” /> L1</a> : My Test File Name<span style=“font-weight: lighter”> (3)</span></td></tr></tbody>
1.If the text in between closing anchor tag “</a>” and beginning span tag “<span” is just 3 characters long (that is " : "), I would like to remove the whole parent tbody tag.
Else, I would like to do the following
-
I would like to replace " L1" between image close tag “/>” and anchor close tag “</a>”. The text " L1" is not static and can be different.
-
I would like to remove " : " which appears after closing anchor tag “</a>”
-
I would like to remove the entire span tag.