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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:09:55+00:00 2026-06-04T14:09:55+00:00

I’m stuck with getting the value attribute of an option in a select list

  • 0

I’m stuck with getting the value attribute of an option in a select list with jQuery Mobile.

My HTML template:

<div data-role="fieldcontain" class="activity ui-hide-label">
  <label for="activity">Activity</label>
  <select name="activity" id="activity">
    <option value="">Activity</option>
    <option value="3">Athlete</option>
    <option value="2">Regular sports</option>
    <option value="1">No sports</option>
  </select>
</div>

My JS function to get the value:

function getValue() {
  var activityValue = $('#activity').val();
  console.log("activity value: ", activityValue);
  localStorage['activity'] = activityValue;
}

Regardless what I choose from the select list, the variable activityValue is always empty. I also tried with option:selected and similar possibilites.

Obviously the DOM select list doesn’t change, when I choose an option. For example, if I choose “Regular sports” the DOM looks like this:

<div data-role="fieldcontain" class="activity ui-hide-label ui-field-contain ui-body ui-br">
  <label for="activity" class="ui-select">Activity</label>
    <div class="ui-select">
      <div data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-icon="arrow-d" data-iconpos="right" data-theme="g" data-inline="false" data-mini="false" class="ui-btn ui-shadow ui-btn-corner-all ui-fullsize ui-btn-block ui-btn-icon-right ui-btn-up-g">
        <span class="ui-btn-inner ui-btn-corner-all">
          <span class="ui-btn-text">Regular sports</span>
          <span class="ui-icon ui-icon-arrow-d ui-icon-shadow">&nbsp;</span>
        </span>
        <select name="activity" id="activity">
          <option value="">Activity</option>
          <option value="1">Athlete</option>
          <option value="2">Regular sports</option>
          <option value="3">No sports</option>
        </select>
      </div>
    </div>
</div>

I’m I missing something? To recapitulate: I need the selected value (1,2 or 3) and NOT the text (“Regular sports” in the above example.

  • 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-04T14:09:57+00:00Added an answer on June 4, 2026 at 2:09 pm

    Well, there is an extra function to get the select changes.

    $('#activity').live( "change", function(event, ui) {
      localStorage['activity'] = $(this).val();
    });
    

    Thanks to Raminson and thecodeparadox for pointing me to the right direction.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I want to construct a data frame in an Rcpp function, but when I

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.