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 7019847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:14:20+00:00 2026-05-27T23:14:20+00:00

I have a button like so: <button id=’abc’ value=[‘fred’, 26]></button> I want to know

  • 0

I have a button like so:

<button id='abc' value=['fred', 26]></button>

I want to know how I can access those two values via JQuery’s .val() function.

I have tried $("#abc").val()[0] but that just appears to give me the first character which is the bracket “[“.

I would like .val()[0] to instead give me the value “Fred”.

  • 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-27T23:14:20+00:00Added an answer on May 27, 2026 at 11:14 pm

    Your HTML is invalid. You should try;

    <button id='abc' value="['fred', 26]"></button>
    

    However, you should look at using valid JSON notation, to enable you to parse the data as an array. JSON requires double quotes for strings (rather than single '), so you should end up with;

    <button id='abc' value='["fred", 26]'></button>
    

    If you were to access $('#abc').val() directly now, you’d retrieve the string ["fred", 26]. To retrieve this data as an array, you should parse the data using jQuery.parseJSON();

    var array = jQuery.parseJSON($('#abs').val());
    for (var i=0;i<array.length;i++) {
        alert(array[i]);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one image submit button like this <input id=enter name=enter type=image value=Login src=images/btn_login.jpg/>
I need a button-like control that can have a Checked property, so that when
I have a button like this: <input type=submit id=product_197_submit_button class=wpsc_buy_button name=Buy value=Add To Cart>
I have a button like this <input type=button id=btnEdit value=Edit Selected class=emrBTN style=top:5;right:95;width:100; visibility:hidden
I have a radio button like this <input type='radio' name='specific_consultant' id='specific_consultant_no' value='no'>No</input> on .on
I have a button like so: <button>Click Me</button> I want to make that button
I have a HTML button like <input type=button id=button onclick=showSuper() value=Click Me! /> Inside
I have a button like this: <input type=button name=btn id=btn value=Proceed/> After all processes
I have a submit button like this: <input class=create_button name=commit onclick=return validate_activity(); type=submit value=Save>
I have a button something like this what should I do? <input type=button value=Exit

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.