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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:48:42+00:00 2026-06-11T23:48:42+00:00

When the page load, I expected <option value=B>B</option> value to change to red. It

  • 0

When the page load, I expected <option value="B">B</option> value to change to red. It didn’t work. Why?

jQuery

$(document).ready(function () {
  $('[name=HeaderFields] option[value="B"]').val('red');
});

Dropdown:

<select name="HeaderFields" style="width:60px">
    <option value="A">A</option>
    <option value="B">B</option>
    <option value="C">C</option>
</select>
  • 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-11T23:48:43+00:00Added an answer on June 11, 2026 at 11:48 pm

    val() sets the value of a form field which in a SELECT is not the same thing as the visible text. This works correctly for me in Chrome with your example by inspecting the source.

    If you are looking to change the visible text, use html() or text().

    See: http://jsfiddle.net/6dSQX/

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

Sidebar

Related Questions

So essentially on page load I want to do the following: <script> $(document).ready(function ()
Q1) On page load is it possible with Jquery to check the file name
I really can't work out what's going on here. I'm using the jQuery load()
I'd like to have a javascript function called on page load and unload which
On page load I'm bootstrapping my data to my collections via this technique .
Is Page.Load the earliest point in the Page.Load life cycle to add Response.AppendHeader?
In my page load, am I calling ReturnStuff() once or three times? If I
I want on page load for the class of a li tag to be
I would like to select the option contained within a php variable on page
I'm currently measuring the time spent to load a web page from a C#

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.