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 :: onclick javascript confirm 
Javascript :: page reload timeout 
Javascript :: This error occurred during the build time and cannot be dismissed. 
Javascript :: updating node js ubuntu 
Javascript :: document ready function 
Javascript :: convert an array of strings to numbers 
Javascript :: react simbu 
Javascript :: 50 50 chance javascript 
Javascript :: jquery script tag source google 
Javascript :: serialize and send form data jquery ajax 
Javascript :: display none js 
Javascript :: responsive slick slider 
Javascript :: Appium click on element Javascript 
Javascript :: check if path is folder js 
Javascript :: how to set an attribute to ignore null value json c# 
Javascript :: jquery replace element 
Javascript :: base64 encode node js 
Javascript :: javascript create element with attributes 
Javascript :: react native flatlist margin bottom 
Javascript :: jquery select on select 
Javascript :: disable console log alert eslint 
Javascript :: jquery set checkbox 
Javascript :: if str contains jquery 
Javascript :: js get current time minutes 
Javascript :: get value from url 
Javascript :: seconds to hh mm ss javascript 
Javascript :: regular expression alphanumeric with spaces java script 
Javascript :: jquery change font size 
Javascript :: check if a variable is array in javascript 
Javascript :: javascript voice reader 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =