// This doesn't work <br>$(this).find('li a').eq(2).text().replace('foo','bar'); <br>// This works <br>var $thirdLink = $(this).find('li a').eq(2); <br>var linkText = $thirdLink.text().replace('foo','bar'); <br>$thirdLink.text(linkText); <br>
// This doesn't work $(this).find('li a').eq(2).text().replace('foo','bar'); // This works var $thirdLink = $(this).find('li a').eq(2); var linkText = $thirdLink.text().replace('foo','bar'); $thirdLink.text(linkText);