Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7506527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:18:16+00:00 2026-05-29T22:18:16+00:00

I have a button on my page with a class of comment_like and an

  • 0

I have a button on my page with a class of comment_like and an ID like comment_like_123456 but the numbers at the end are variable; could be 1 to 1000000.

When this button is clicked, I need to grab the end number so I can run tasks on other elements with the same suffix.

Is there an easy way of grabbing this number in jQuery?

$('.comment_like').click(function() {
    var element_id = $(this).attr('id');

    // grab number from element ID

    // do stuff with that number

});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:18:16+00:00Added an answer on May 29, 2026 at 10:18 pm

    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
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cancel button on a page. But this page can be opened
I have a button on my page. When clicked it triggers an ajax call
I have a button on an html page declared like so: <button type=submit name=action
I have page like this: <ul id=cards> <li id=card1> <div>...</div> <div id=panel1> <form>...</form> <ol
I have a facebook like button in my web site in the home page.
I have a like button that is loaded from ajax on to my page.
I have the FB like button on main page and other pages. And the
I have a button called Download page at the bottom of my detailView of
I have a button on my page and and few textboxes which alters their
I have a button in my page, and onclick event, if should append to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.