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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:53:22+00:00 2026-05-24T13:53:22+00:00

I have the following snippet of a HTML select box: <select id=Obj_cboscreen class=menubarselect name=page>

  • 0

I have the following snippet of a HTML select box:

<select id="Obj_cboscreen" class="menubarselect" name="page">
<option att="1stOption" value="0" selected="">abc</option>
<option att="2ndOption" value="1">def</option>

When I run the following pieces of code:

var attribute = $('#Obj_cboscreen :selected').attr('att');
var name = $('#Obj_cboscreen :selected').html();

I get 1stOption and abc (respectively).

When I change the select box to a different option, for example:

<select id="Obj_cboscreen" class="menubarselect" name="page">
<option att="1stOption" value="0">abc</option>
<option att="2ndOption" value="1" selected="">def</option>

I get the same results of the output before.

“1stOption and abc”

Now I noticed the selected=””. That doesn’t look right, I’ve looked around in the project and I’m unable to find where that is being produced, but it is rendering properly.

I’m wondering why the selected selector isn’t working properly?

  • 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-24T13:53:23+00:00Added an answer on May 24, 2026 at 1:53 pm

    The following code works for me –

    var attribute = $('#Obj_cboscreen :selected').attr("att");
    var name = $('#Obj_cboscreen :selected').html();
    
    alert(attribute + name);
    

    There are a couple of changes from your code.

    attr(att) to attr("att")

    $('#Obj_cboscreen:selected') to $('#Obj_cboscreen :selected')

    The following jsfiddle shows the code working when the ‘selected’ attribute is added to the second option.

    http://jsfiddle.net/ipr101/bjWt3/

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

Sidebar

Related Questions

I have the following html snippet: <a href=page1.aspx class=title>page title goes here</a><br /> <span
I have the following html snippet <table> <tr> <td><select name=day> </select></td> <td><select name=time> </select></td>
I have the following HTML (a snippet): <td class=ms-vb-title height=100%> <table class=ms-unselectedtitle onmouseover=OnItem(this) ctxname=ctx1
I have the following HTML snippet: <body> <div class=main> <div class=topBar> <p>testing</p> </div> <div
I have the following html snippet: <div id=contentX><h1>MyHeading1</h1></div> I could select with jQuery snippet
I have the following HTML snippet: <span class=target>Change me <a class=changeme href=#>now</a></span> I'd like
I have following html snippet: <div class=rsw-pp rsw-pp-widget> <div g:type=AverageStarRating g:secondaryurls=http://maps.google.com/?cid=12948004443906002997 g:decorateusingsecondary=http://maps.google.com/?cid=12948004443906002997 g:groups=maps g:rating_override=2.998000
I have the following snippet in one of my html pages : <div class=inputboximage>
I have the following html snippet <ul class=product> <li><span>Available:</span>123</li> <li><span>Code:</span>12345</li> </ul> What I'm looking
Consider the following HTML snippet. The desired effect is to have a dropdown be

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.