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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:48:51+00:00 2026-06-02T19:48:51+00:00

I am wondering if there is an easy solution to this: I have the

  • 0

I am wondering if there is an easy solution to this:
I have the following JQuery plugin created several times on elements defined in a grid

(function ($) {
    $.fn.MyPlugin = function () {

        $(this).mouseenter(function () {
           //do something for single plugin instance
        });
    };

})(jQuery);

However, how can I go about uniquely identfying which plugin instance I am triggering the mouse enter function on. With the current setup I am referencing all the instances, but I want to only trigger the mouseenter for one of them at the time.

The plugin is created like this:

$(".someClass").MyPlugin(); 
  • 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-02T19:48:53+00:00Added an answer on June 2, 2026 at 7:48 pm

    You don’t need to create a plugin mutiple times, that’s why it’s called a plugin. You just plug it in wherever you want. Take a look at the jquery plugins authoring page on how to start coding a plugin. It provides some nice templates.

    In your code $(this) is redundant, since this is already a jQuery object. Then, you’d want to always return this to maintain chainability in your plugin. You can use $(this) inside the mousenter event to reference the current element being processed by the plugin in the DOM.

    Sometimes it’s also useful to return this.each() and loop each element and do something. In this case, since you’re attaching an event it doesn’t help because an event works on every item in the collection of items; in this case, this refers to the collection on which you called the plugin:

    $.fn.MyPlugin = function () {
    
        return this.mouseenter(function () {
           $(this).something();
           //do something for single plugin instance
        });
    
    };
    

    Then you’d call the plugin like so:

    $('elements').MyPlugin();
    

    Just call the plugin on the element(s) that you want and those elements will have the mouseenter event attached.

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

Sidebar

Related Questions

There has to be a easy solution to this. I have been trying to
I was wondering (there has to be an easy solution) if there is a
Failing to find a solution to this question I was wondering if there was
I am wondering if there's an easy way to detect phrases in two strings
I was wondering if is there an easy way to generate views from form
I'm using TFS 2010 and am wondering whether there is an easy way, either
Hey, I'm just wondering if there's any easy function to make text suitable to
I'm wondering if there is a free script or easy tutorial on how to
I'm wondering if is it there any easy, and common between .NET and Mono,
I am wondering say I have this string Hi my name is chobo2 and

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.