Example url:
www.example.com/example/createnew/#47
or
www.example.com/example/createnew/#5462
I want to put the number behind the '#' in a variable. but the size of the number can change.
how do i do this?
(without jquery or any other library)
Example url:
www.example.com/example/createnew/#47
or
www.example.com/example/createnew/#5462
I want to put the number behind the '#' in a variable. but the size of the number can change.
how do i do this?
(without jquery or any other library)
 
    
    You can use split()
var res = 'www.example.com/example/createnew/#5462'.split('#')[1],
  res1 = 'www.example.com/example/createnew/#47'.split('#')[1];
document.write(res + '<br>' + res1); 
    
    var url = 'www.example.com/example/createnew/#5462';
var num = parseInt(url.match(/\d+$/)[0]);
 
    
    try this:
var val = "www.example.com/example/createnew/#422";
var myString = val.substr(val.indexOf("#") + 1)
alert(myString);