I need to change the class of a span based upon the existence of a table, further on down the html structure.
Basically, the html is built dynamically, using code behind on a c# page, which is then appended to div tag. This all works perfectly, fine, but now I have a need to change the class value of a span tag, if the presence of table is found.
So, the structure looks something like this:
<tr>
<td><span class="badge badge-default"></td>
<td>some stuff</td>
<td><table id="hitTable"></tr>
</tr>
In the above example the second td after the span, does contain a table with the id of hitTable, in this case I need use JQuery to change the class of span, to badge badge-danger.
I'm not sure, how to traverse up, once I've identified the table.
This code will change any spans, within the table, but how do i change the first span outside of the table?
$('table[id^="hit"] span').addClass('badge badge-danger');