PI.
PI.

Reputation: 1668

Search a string for a specific word, then change it

I have a number of tags which have title's that specify both a contract type and the contract provider.

What I am trying to do is take the title tag and store it within an array and replace all with dashs.

Problem is, there is a a specific format which the contract type has to be stored in. At the moment 'payg' is correct, but because of how it is marked up I don't know how to replace the 'pay monthly' with 'paym'

Please find my code here: http://jsbin.com/ikumar/4/edit/

I don't have access to the markup too.

B

Upvotes: 0

Views: 112

Answers (2)

billyonecan
billyonecan

Reputation: 20260

$anaLinksTitle = $anaLinksTitle.toLowerCase()
                 .replace(/ /g, '-')
                 .replace('pay-monthly', 'paym');

Upvotes: 0

Geert
Geert

Reputation: 1227

http://www.w3schools.com/jsref/jsref_replace.asp

$anaLinksTitle = $this.attr('title').replace("pay monthly", "paym");

Upvotes: 1

Related Questions