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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:55:23+00:00 2026-05-26T15:55:23+00:00

I have a plugin which is applied on few element. Is there any way

  • 0

I have a plugin which is applied on few element. Is there any way to store and retrieve JQuery plugin object so that we can run method of that object. A sample example is:

$('#li1').myPlugin(); // apply plugin object to different li
$('#li2').myPlugin(); // apply plugin object to different li
$('#li3').myPlugin(); // apply plugin object to different li

Now I want to retrieve the object from user activity on other external element, to run some method of the plugin. Like

var idx = 2    
$('body').click(function(){ $('li').eq(2).highLight(); })

Since highLight is public method of myPlugin but not li, so it won’t execute.
Can I set myPlugin object as attribute to the element (but its not string) or can I do this way within plugin initialize,

$(this)[0].obj = this; // sounds weird.

What are the other option other than creating global associative array to store object with element Id as key. This is not possible in my case, as my plugin elements may or may not have Id.

EDIT

This is sample plugin, actual is too big to post here. Objective is to identify the plugin associated with element, by external activity. Sample example is using body.click but assume we cannot implement click inside my plugin. Actually events could be any external custom events which are not known to the plugin. I hope I am clear.

 (function ($) {
    $.fn.myPlugin = function (){
        var ele = this;

        // elr.get(0).extension = this; // can I do this, cross browser?
        // so that later i can call it as 
        // $('li').eq(1).get(0).extension.highLight()

        this.highLight = function(){
             ele.css('color','red');
        }
        this.blueIt =  function(){
             ele.css('color','blue');
        }
        this.blueIt();
    }
 })(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-05-26T15:55:24+00:00Added an answer on May 26, 2026 at 3:55 pm

    The two main alternatives are to use the .data() jQuery method to store a reference to whatever you need, or use the convention of $(sel).pluginName("aMethod", anyData).

    I’ve never been a huge fan of the latter, but it’s common.

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

Sidebar

Related Questions

I have a custom jQuery plugin which binds a change event to a form
Is there a firefox plugin which functions as an SVN client? I have checked
I have a engine style Rails plugin from which I can create a gem
Do you have any idea how to create IE plugin which will save to
I have a plugin which at present doesn't have any extension points (neither does
I have the following code which applies the jQuery UI Sortable plugin to all
Currently I have a jQuery plugin which not only sets up its function in
I have a jQuery plugin which works like most plugins in this format $(somelement).SomePlugin(some
Hi I have a plugin.dll which contains this all npp functions I have embeded
I have findbugs plugin for eclipse which when run on my project will show

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.