not able to change text inside span
I have a simple jquery script to change text inside a span tag, which is inside a legend tag ,but its replacing even the text in legend.
here is my script
- $(document).ready(function(){
- $('legend').click(function(){
- $(this).nextAll().toggle();
- $(this).next().is(":visible")? $(this).find('span').text('(-)'):$(this).first('span').text('(+)') ;
- event.preventDefault();
- });
- })
my html
- <fieldset>
- <legend >Recommendation Code Details <span>(-)</span> </legend>
- <table style="margin-bottom: 0pt;" class="freeform">
- <tbody>
- <tr>
- <td>
- <table style="margin: 0pt;" class="search">
- <tbody>
- <tr>
- <td class="bold">
- Recomendation Code:
- </td>
- <td valign="top">
- <label style="font-weight: normal;" wicket:id="findingNumber">209928100</label>
- </td>
- </tr>
- <tr>
- <td class="bold">
- Recommendation Code Type:
- </td>
- <td valign="top">
- <label style="font-weight: normal;" wicket:id="findingType">Monetary</label>
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </fieldset>
Please advice.