Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery extract number from string

var id_of_div = "div_id_12";
var id_number = parseInt(id_of_div.replace(/[^0-9.]/g, ""));
console.log(id_number);//12
Comment

get number from string using jquery

You can get it like this:

var suffix = 'comment_like_123456'.match(/d+/); // 123456

With respect to button:

$('.comment_like').click(function(){
  var suffix = this.id.match(/d+/); // 123456
});

It works for me.
Comment

PREVIOUS NEXT
Code Example
Javascript :: add item to list javascript 
Javascript :: firebase cloud functions schedule function run time 
Javascript :: hide browser address bar javascript 
Javascript :: jquery format date 
Javascript :: write own nodemon in package.json 
Javascript :: add char in specific index stirng javascript 
Javascript :: jquery remove child 1 elemtn 
Javascript :: javascript insert item into array 
Javascript :: moment js react 
Javascript :: clear input field jquery 
Javascript :: javascript classlist add 
Javascript :: toggle button by javascript 
Javascript :: javascript join 
Javascript :: get odd number in array 
Javascript :: javascript append to array 
Javascript :: js onscroll event 
Javascript :: how to install react router dom 
Javascript :: jsx foreach 
Javascript :: android force date inside RecyclerView to re render 
Javascript :: how to use hidden in div in angular 
Javascript :: how to make view dotted line in jsx 
Javascript :: inline confirm box javascript 
Javascript :: Reading Time with jquery 
Javascript :: javascript quicksort 
Javascript :: js addeventlistener hover 
Javascript :: javascript replace 
Javascript :: Both npm and yarn have created lockfiles for this application, but only one can be used to install dependencies. 
Javascript :: btoa javascript 
Javascript :: element ui handle enter key 
Javascript :: angular 404 on refresh 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =