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
please check below javaScripts, there you can get only number
var txt = "abc1234char5678#!9"; var str = txt.match(/\d+/g, "")+''; var s = str.split(',').join(''); alert(Number(s));
output : 1234567789
1234567789