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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:25:39+00:00 2026-06-13T03:25:39+00:00

I have five different input controls on a page, each with a different id

  • 0

I have five different input controls on a page, each with a different id and name, and a class as well.

<input id="txtName1" name="txtName1" class="jName" type="text" />
<br />
<input id="txtName2" name="txtName2" class="jName" type="text" />
<br />
<input id="txtName3" name="txtName3" class="jName" type="text" />
<br />
<input id="txtName4" name="txtName4" class="jName" type="text" />
<br />
<input id="txtName5" name="txtName5" class="jName" type="text" />

Which is the more efficient manner when using jquery to select a group of inputs by to register the blur event? The reason I ask is because I actually have 20 of these input controls on the page and I want the jquery select to be as quick as possible.

1) Select by tag id:

$(document).on("blur", "input[id*='_txtName']", function ($e) {
  alert("blur event successful");
})

or

2) Select by class:

$(document).on("blur", ".jName", function ($e) {
  alert("blur event successful");
})

EDIT:
My intent here is to hook the blur event up to all of the input elements in the code above. Sorry for the confusion here, folks.

  • 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-13T03:25:40+00:00Added an answer on June 13, 2026 at 3:25 am

    Couple things:

    1. You are using the same id value on all those elements. Don’t do that, they’re supposed to be unique.
    2. Looking up by class is much faster in this case, since a class selector is faster than an attribute selector.

    Performance test: http://jsperf.com/id-regex-vs-class

    In the HTML on that test, I did change your id values to be unique. I’m also using the attribute starts with selector instead of the ends with.

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

Sidebar

Related Questions

I have five combo boxes. Each one has a different name, but the possible
I have five consumers and one producer. The five consumers each output different data,
I have five fields for number input, and each of these fields must be
in my C project I have five different function (with the same name) which
I have an html form (each form has different page, according to date), with
I have a form like this: <form action='' onsubmit='void(0)' class=mainform> <label class=form3><input type=checkbox> One
I have five separate services where each one corresponds to a different database table
I have created an application which stores a set five different times, at each
I have five different websites set up using Wordpress 3.0 Multisite. They each contain
i have multiple search forms, for five different databases (tables) each form contains about

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.