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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:21:18+00:00 2026-05-24T12:21:18+00:00

I am working on a project where I have a select tag with its

  • 0

I am working on a project where I have a select tag with its options being generated in a javascript function. I am currently populating the “title” attribute of each option with a detailed description.
Inside the javascript function I am currently doing something like this:

var country = new Option("countryUSA", "United States of America");
$("#mySelect").get(0).options[1]=country;

This works fine, the option shows up. However, I also need to set the “title” attribute of that html option element. I have tried something like this:

country.title="Full description of USA";

but it does not work.
I know I can do something like this:

 $("#mySelect").get(0).options[1].title="My title";

but I was trying to set the title before adding the option to the select tag. Isn’t the “Option” object suppose to allow me to set the “title” property? The javascript function is not even executed. Is there no way I can set the “title” attribute for an “option” html element in javascript?

  • 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-24T12:21:19+00:00Added an answer on May 24, 2026 at 12:21 pm

    It looks like you’re using jQuery. There is a much simpler way to do what you want. Just use the jQuery API rather than regressing back to vanilla DOM:

    $('<option>',
    {
        value: 'countryUSA',
        title: 'Full description of USA',
        text: 'United States of America'
    }).appendTo("#mySelect");
    

    That said, do you expect setting the title to make a browser-native tooltip to appear while the hovering over the <option>? At least in Chrome, no such tooltip will appear.

    Try it yourself: http://jsfiddle.net/GMTLn/1/


    Edit Chrome and Safari do not show a tooltip on <option>s with a title attribute because WebKit doesn’t. See this bug report.

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

Sidebar

Related Questions

I'm working on a project where i have to select multiple options in drop
I am currently working on a project involving the canvas element and have come
So I have been working on a project and I have a function that
I working on project and have problem with threading and update of UI. I
I have a working project that Im amending, it crashes after trying to use
I have a project working fine under MSVS 2010 SP1. I'm trying to convert
I am working on project where I have the checkInternet method in one of
I’m working on a project and have developed the high level user requirements for
I am working on a project and have the following psuedocode: // create a
Working on a project where they have lots of enums and lots of duplicated

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.