I have a string in JavaScript like #box2 and I just want the 2 from it.
#box2
2
I tried:
var thestring = $(this).attr(\'href\'); var
You can use regular expression.
var txt="some text 2"; var numb = txt.match(/\d/g); alert (numb);
That will alert 2.