I want to replace my title from its default to "*number* new messages | default"
Here is the code I have, it changes from default to 1 new messages fine, but it never goes above 1.
title = $('title').text();
regexp = /^(\d+)/
if (title.match(regexp))
$('title').text().replace(regexp, (parseInt("$1")+1).toString())
else
$('title').text('1 New Messages | Default')
You should be using a function as the second argument to
replace, you also need to set the new value:And, as usual, don’t forget the radix argument when you call
parseIntor you will be unpleasantly surprised sooner or later.