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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:20:37+00:00 2026-05-23T12:20:37+00:00

I learned that using a reference variable is faster than using $() every line

  • 0

I learned that using a reference variable is faster than using $() every line of code (see my previous question): jQuery – Is it okay to use $('#ElementId') everytime?. Now my question is how can I use this reference variable to maximize the power of jQuery? Please see the example below:

Without reference variable:

var ValueOfSelected = $('#SelectElementId option:selected').val();

With reference variable (pseudo-code):

var SelectElement = $('#SelectElementId');
var ValueOfSelected = $(SelectElement).SelectedOption.val();

Note that SelectedOption.val() is the pseudo-code here. Is there such function anyway?

  • 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-23T12:20:37+00:00Added an answer on May 23, 2026 at 12:20 pm

    You can use .find() to find the nested option.

    var SelectElement = $('#SelectElementId');
    var ValueOfSelected = SelectElement.find('option:selected').val();
    

    …but because it is a select element, you can just use the val()[docs] method directly.

    var SelectElement = $('#SelectElementId');
    var ValueOfSelected = SelectElement.val();
    

    This will give you the value of the selected option.

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

Sidebar

Related Questions

I learned that by trying to use the tablesorter plug in from jquery the
I have learned that when using android:entries with a ListView , it uses android.R.layout.simple_list_item_1
In OO Javascript constructor pattern: neo-classical vs prototypal , I learned that constructors using
I am using jQuery 1.5 in my open source project and following line is
When I read litb answer to this question , I learned that passing an
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
I learned that compiler will expand macros while compiling. Templates are also expanded at
I learned that when executing commands in Python, I should use subprocess. What I'm
I've learned that static scoping is the only sane way to do things, and
So I have learned that that the Microsoft.Jet.OLEDB.4.0 data provider for querying data sources

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.