Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if an a link contain something in the href change the href to this

i want to check if the href contains 'coming-soon' if it does change the href to go to my products page:

$('a[href$="coming-soon"]').attr('href', '/products.aspx');

cant work this out.

like image 892
phil crowe Avatar asked Nov 30 '10 17:11

phil crowe


1 Answers

$= is "attribute-ends-with", use *= for "attribute contains", like this:

$('a[href*="coming-soon"]').attr('href', '/products.aspx');
like image 55
Nick Craver Avatar answered Oct 06 '22 00:10

Nick Craver