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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:02:10+00:00 2026-05-26T22:02:10+00:00

I am able to set the selected item in an html select item using

  • 0

I am able to set the selected item in an html select item using jQuery’s val() function. For example,

<select id="selector">
    <option></option>
    <option>Care Bears</option>
    <option>Yo Gabba Gabba</option>
</select>

<input id="selectButton" type="button" value="Care Bears" />

$('#selectButton').click(function() {
    $('#selector').val('Care Bears');//change the selected value to care bears
});

But, if I modify the code slightly,

<option value="">Care Bears</option>

val() breaks. Why is this?

  • 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-26T22:02:11+00:00Added an answer on May 26, 2026 at 10:02 pm

    Because there is no longer an <option/> that matches "Care Bears" in the value attribute.

    HTML defaults the value attribute of the <option/> tag to the Contents, if not otherwise specified.

    This is actually part of the Javascript Spec as noted in the comment below.

    Example to show vanilla javascript functionality

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

Sidebar

Related Questions

I created a CustomButtonField in blackberry using that i can able to set our
I want to know how to set the background of a selected item in
I want to be able to set my country of origin - does this
Would like to be able to set colors of headings and such, different font
I need to be able to set the size of an array based on
I want to be able to set variables in a template to string values.
In a basic mysql insert you are able to set a password variable 'PASSWORD($password)'
Im extending the UIButton Class to be able to set the font and color
I'm writing an application and I'm able to set its throughput (the number of
I have a table and I would like to be able to set up

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.