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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:00:56+00:00 2026-06-03T01:00:56+00:00

I have this plain js: var innerText = document.getElementById(TaskId).options[0].text; And I was wondering how

  • 0

I have this plain js:

var innerText  = document.getElementById("TaskId").options[0].text;

And I was wondering how to convert it to jQuery:

var innerS = $("#TaskId");
var innerText = innerS.options[0].text;

This throws an error:

innerS.options is undefined

EDIT

In accordance with some of the debate I threw a quick speed test together:

js:

var startDat = Date.now();
for (var c = 0; c < 100000; c++) {
    var com = $("#TaskId").get(0);
}
var endDat = Date.now();
alert("jQ.get(0) took " + (endDat - startDat) + "ms");


var startD = Date.now();
for (var co = 0; co < 100000; co++) {
    var com = $("#TaskId")[0];
}
var endD = Date.now();
alert("jQ[0] took " + (endD - startD) + "ms");

var startDa = Date.now();
for (var comp = 0; comp < 100000; comp++) {
    var compa = document.getElementById("TaskId");
}
var endDa = Date.now();
alert("js took " + (endDa - startDa) + "ms");

results:

jQ.get(0) took 1042ms
jQ[0] took 1057ms
js took 136ms
  • 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-03T01:00:58+00:00Added an answer on June 3, 2026 at 1:00 am

    A jQuery object contains an array of DOM elements. If you want direct access to the DOM elements, there are a number of ways to get that direct access. For example, you can directly get the first DOM element with this:

    var innerS = $("#TaskId").get(0);
    

    Now innerS is the actual DOM element and not a jQuery object any more.

    For fastest execution time, use:

    var innerS = document.getElementById("TaskId");
    

    jQuery can be fast to code with, but is not always the fastest for execution time as jQuery objects carry some overhead with them (constructing them, sorting DOM elements, etc…).

    You can get the entire DOM array like this:

    var optionElements = $("option").get();
    

    Of course, one of the reasons for using jQuery objects is that they have a set of cross-browser methods that make it easy to just use their methods instead of the direct DOM methods in some cases. In your particular case, you could get the innerText like this:

    var text = $("#TaskId").text();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have something like this: if ($command === 'txt') { header('Content-type: text/plain;charset=utf-8'); echo
I send data in this way: <form method=post enctype=text/plain action=Func> And I have a
I have this: var targetTitle = targetElement.getElementsByTagName('title').item(0); Am i passing a plain string into
I have a form with a bunch of plain numbers and telephone. Like this
I have some javascript that looks like this: var sel = '<option value={value} {selected}>{name}</option>';
I have something like this: var users = []; Then I use this to
I have some javascript code like this, var worker = new Worker(javascript/worker.js); worker.onmessage =
The system have a plain enum like this, public enum SomeEnum : short {
I'm trying to have plain (no jQuery, mootools, etc) JavaScript add span tags with
I have an NHibernate LINQ query like this: var maxNumber = session .Linq<Child>() .Where(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.