tags:

views:

17

answers:

1

Hi,

I have the html below:

<span class="srch-URL">
<a id="CSR_U_2" href="http://www.test.com/TestForm.aspx"&gt;http://www.test.com/TestForm.aspx&lt;/a&gt;
</span>

I am trying to use JQuery to find all elements matching the class 'srch-URL' then change the link contained with them if they end in TestForm.aspx by appending &Source=/default.aspx to the link.

The JQuery below would check all links containing TestForm.aspx

$('a[href*="TestForm.aspx"]')

but I need to do this only for if contained in the class 'srch-URL' then append the &Source parameter...

+1  A: 

Try:

$( 'span.srch-URL a[href*="TestForm.aspx"]' )

And if you're unsure on how to change the url, try:

$( 'span.srch-URL a[href*="TestForm.aspx"]' ).each(function(){
    $( this ).attr( 'href', $( this ).attr('href') + '&Source=/default.aspx' )
});
hookedonwinter
changing the url worked great, thanks alot, nav
nav