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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:05:16+00:00 2026-06-14T05:05:16+00:00

I have a button , a div and a select combo-box I want to

  • 0

I have a button, a div and a select combo-box

I want to execute a particular function on click of the button, on mouseenter in div and onchange and blur of the combobox

I do this right now

$("#divID").bind('mouseenter',function(){

   // do my stuff
}) 

$("#comboID").bind('blur change',function(){

   // do my stuff
})  

$("#buttonID").bind('click',function(){

   // do my stuff
})  

I do the same stuff everytime. I want to combine all the events together to avoid duplication is there a way to bind each one of the elements with specific events in one statement

I know I can write the code in a separate function and call it each time(solves duplication).

But I want to know can this be done without a separate function and only jQuery

  • 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-14T05:05:17+00:00Added an answer on June 14, 2026 at 5:05 am

    You have seprate event with seprate selectors so one selector or event is not enough, you can map ids and events. I think jquery could not help much to make it single statment.

    Live Demo

    arrIDs = ['divID','comboID','buttonID'];
    arrEvents = ['mouseenter','blur change','click'];
    
    for(idx=0; idx < arrIDs.length; idx++) 
        $("#" + arrIDs[idx] ).bind(arrEvents[idx], yourFunction);
    
    function yourFunction(event)
    {
        alert("yourFunction call by " + event.target.id);  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div that I want when user click on a button slideUp
I have the following function to remove a DOM element div, $('#emDiv').on(click, ':button[data-emp-del=true]', function
I have a div which opens when I click a menu button, I am
I want to select the contents of a DIV (like highlight when you click
In web-code I have a button: <div id="net-equipment-button_config-1037" class="x-btn x-box-item x-toolbar-item x-btn-default-small x-noicon x-btn-noicon
I have a button named okbutton. A callback function is bind to the click
Given that I have a button within a div: <div id=result> <a href='#task5'> <img
I have a button which creates a div. Once clicked I would like to
I have a button which when toggled displays/hides a div ('.reportOptions'), this works perfectly
I have a link button inside UpdatePanel in a div popup. On Button_Click, I

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.