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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:14:03+00:00 2026-05-16T02:14:03+00:00

I am new to JQuery I am writing a simple data validation using JQuery.

  • 0

I am new to JQuery
I am writing a simple data validation using JQuery.

Here is the HTML part:

<input type="text" id="testing">

This is the JQuery part:

$(document).ready(function(){ 
   $("#testing").click(function(){
     // doing something;
      });

$("#testing").change(function(){
      // doing something;
      });

$("#testing").mouseover(function(){
      // doing something;
      });
});

$(“#testing”) repeated three times in my sample code, is it possible to simplify this?
I am not sure if bind() can help solve the question.

  • 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-16T02:14:04+00:00Added an answer on May 16, 2026 at 2:14 am

    you could do the following

    $(document).ready(function() {
        var testing = $('#testing');
        testing.click(function() { });
        testing.change(function() { });
        testing.mouseover(function() { });
    });
    

    or (using chains):

    $(document).ready(function() {
        /* var testing = */ $('#testing') // the assignment is optional, but you can reuse the selector
            .click(function() { })
            .change(function() { })
            .mouseover(function() { });
    });
    

    with bind you can create eg. custom eventhandlers:

    $(document).ready(function() {
        var testing = $('#testing');
        testing.bind('fill', function() { });
        testing.trigger('fill');
    });
    

    as reading through the docu, you could also do:

    $(document).ready(function() {
        /* var testing = */ $('#testing') // the assignment is optional, but you can reuse the selector
            .bind('click change mouseover', function() { });
    });
    

    or with jquery 1.4:

    $(document).ready(function() {
        /* var testing = */ $('#testing') // the assignment is optional, but you can reuse the selector
            .bind({
                    click: function() { },
                    change: function() { },
                    mouseover: function() { }
            });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to JQuery, and I am attempting writing code using PHP, HTML,
New to jQuery and having simple yet confusing problem. ha2. I am writing this
im new to jquery and javascript.. Here is the code, this is a sample,
I'm very new to jQuery and I'm writing some validation logic on a form.
New to jQuery/javascript here and looking for a little help. I am writing a
I'm writing a jQuery plugin for work which pulls in RSS feed data using
When writing a new jQuery plugin is there a straightforward way of checking that
I am writing an ajax script in jQuery. The script gets new or previous
I have just started learning Jquery and am new to writing javascript (I am
Using jQuery UI 1.8rc3 combined with the new jquery.effects.fade.js code, I've been able to

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.