okay i have changed it a little bit as follows:
- $('#catprods_tbl tbody tr td.column_main font').each(function() {
- var t = $(this).text().trim();
- var first = t.indexOf("%) ");
- var last = indexOf(" (£");
- var begin = t.substr(0, first);
- var end = t.substr(last);
- $(this).text(begin+"off RRP"+end);
- })
- $('#catprods_tbl tbody tr td.column_main font')
givs you the wanted selection
- var t = $(this).text().trim();
this is the actual text, the first one is "(60%) off RRP (£75.00)"
the .trim() is for deleting blanks at the start or the end of a string
- var first = t.indexOf("%) ");
"
%) " are the last chars before the expression we are looking for
"off RRP"
- var begin = t.substr(0, first);
this gives us for example "(60%) ", the part of the string from 0 until first
var end is nearly the same.
now we have a string before "off RRP" and a string after "off RRP"
we can build a new string
begin +"off RRP"+end and assign it to the .text() method
that's it