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

  • Home
  • SEARCH
  • 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 7832991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:31:00+00:00 2026-06-02T12:31:00+00:00

JSFiddle $(.commentbox).on(click,.btnSave,function(){ var id = $(this).attr(id).split(-); alert(id); id.shift(); alert(id); var newString = id.join(‘-‘); alert(newString);

  • 0

JSFiddle

$(".commentbox").on("click",".btnSave",function(){


         var id = $(this).attr("id").split("-");
            alert(id);
            id.shift();
            alert(id);
            var newString = id.join('-');
            alert(newString);


   });       
});​

Input is btnSave-88eC4B8D2-8F96-4EB5-B42E-08C540D7F171

Output :88eC4B8D2,8F96-4EB5,B42E,08C540D7F171

Whereas it works fine for btnReply button Why
Please help me out

  • 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-06-02T12:31:02+00:00Added an answer on June 2, 2026 at 12:31 pm

    Is this a trick question ? 🙂


    The problem is with this line of code

    <input type='button' class='btnSave' value='Save' id='btnSave-" + id + "' /> "
    

    Here id passed is actually id="btnSave-88C4B8D2,8F96,4EB5,B42E,08C540D7F171" because id is an array and that array got converted to a comma separated string because you set it as string attribute. Now you call split(-) on that string which gives you “btnSave” and “88C4B8D2,8F96,4EB5,B42E,08C540D7F171”. Now you shift and remove the btnSave leaving the single member “88C4B8D2,8F96,4EB5,B42E,08C540D7F171” and then you call join(“-“) on that single string which doesn’t change a thing at all. So, all you have to do is change the above shown like like this

    <input type='button' class='btnSave' value='Save' id='btnSave-" + newString + "' /> "
    

    Fiddle here: http://jsfiddle.net/naveen/XHr6e/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(function() { $(.commentbox .btnReply).click(function() { $(this).hide(); var id = $(this).attr(id).split(-)[1] var strDiv = <input
http://jsfiddle.net/rFEER/ <select id=users> <option value=1>jack</option> <option value=2>brill</option> <option value=3>antony</option> </select>​ js: $(#users).change(function(){ alert($(this).val()); })​
JSFIDDLE $(document).ready(function() { $(.chk).click(function() { $(.chk:checked).each(function() { $(.+this.id).show(); }); $(.chk:not(:checked)).each(function() { $(.+this.id).hide(); }); //
JSFiddle: http://jsfiddle.net/KH8Gf/27/ Code: $(document).ready(function() { $('#expand').click(function() { var qty= $('#qty').val(); for (var counter =
Jsfiddle: http://jsfiddle.net/yJJs7/ Javascript: function main(){ var centerx=250; var centery=250; var degrees=0; var div=document.getElementById('test'); var
http://jsfiddle.net/vzBZB/5/ (function(){ var i = 1; var start = true; setInterval(function(){ if (i>0&&start){ var
jsFiddle: http://jsfiddle.net/KUcrm/ I have this code: HTML <input id=Check1 type=checkbox name=ckbRG tabindex=1 checked /><label
JSFiddle URL: http://jsfiddle.net/sFe45/ Code: <html> <head> <title>Foo</title> <script type=text/javascript> var target; var anchor; function
http://jsfiddle.net/9BCrs/5/ I have this set up to load a file into a DIV using
jsFiddle I'm trying the get the ID of a button using $(this).id , but

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.