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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:05:27+00:00 2026-05-22T12:05:27+00:00

I am using this code: $(‘div.x’).find(‘#y’).live(‘click’, function(e) { var aa = $(this); if (aa.find(‘a’).length

  • 0

I am using this code:

 $('div.x').find('#y').live('click', function(e) {

        var aa = $(this);

    if (aa.find('a').length == 0) {

        aa.find('div.z').hide();

        aa.find('input:submit').click(function(e) {
            //...................
        });

        aa.append('xxx');
        $('html, body').animate({ scrollTop: 100 });
    }
    e.preventDefault();

});


$('body').click(function(e) {
    $('div.tt').slideUp('slow');
});

$('div.uu').delegate('div.gg', 'click', function(e) {
    e.stopPropagation();
});

Now I want the above piece of code into jQuery plugin. Can you tell me how can I make it? how to accept defaults from outside so that the div classes can be taken from outside instead of keeping that hardcoded in plugin?

  • 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-22T12:05:27+00:00Added an answer on May 22, 2026 at 12:05 pm

    You can use this and you just change a few things:
    https://github.com/OscarGodson/jQuery-Plugin-Skeleton

    This is untested, but i believe it should work:

    /*
        Copyright (c) <Year> <First & Last Name>, <Your Web Site>
    
        Permission is hereby granted, free of charge, to any person obtaining
        a copy of this software and associated documentation files (the
        "Software"), to deal in the Software without restriction, including
        without limitation the rights to use, copy, modify, merge, publish,
        distribute, sublicense, and/or sell copies of the Software, and to
        permit persons to whom the Software is furnished to do so, subject to
        the following conditions:
    
        The above copyright notice and this permission notice shall be
        included in all copies or substantial portions of the Software.
    
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
        EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
        NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
        LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
        OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
        WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    */
    (function($){
        $.fn.pluginname = function(options) {
            var settings = $.extend({}, $.fn.pluginname.defaultOptions, options);
    
            return this.each(function() {
                var $this = $(this);
    
    
          $this.find('#y').live('click', function(e) {
    
              var aa = $(this);
    
              if (aa.find('a').length == 0) {
    
                  aa.find('div.z').hide();
    
                  aa.find('input:submit').click(function(e) {
                      //...................
                  });
    
                  aa.append('xxx');
                  $('html, body').animate({ scrollTop: 100 });
              }
              e.preventDefault();
    
          });
    
    
          $('body').click(function(e) {
              $('div.tt').slideUp('slow');
          });
    
          $('div.uu').delegate('div.gg', 'click', function(e) {
              e.stopPropagation();
          });
    
            });
        };
    
        $.fn.pluginname.defaultOptions = {
        };
    })(jQuery);
    

    Youd use it like this:

    $('div.x').pluginname();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using this code: $(document).ready(function () { var breadCrumps = $('.breadcrumb'); breadCrumps.find('span').text(<%= ArticleSectionData.title %>);
Im using this code to restrict the user to not enter special characters $(input).keyup(function(){
Using this code v=new Date(); var bxx=document.getElementById('bxx'); function t(){ n=new Date(); ss={time}; s=ss-Math.round((n.getTime()-v.getTime())/1000.); m=0;h=0;
I Using this code <script type=text/javascript> $(function() { $('#DoTask').click(function(event) { event.preventDefault(); // added this
Im using this code for mysql connection $con = mysql_connect(localhost:/var/lib/mysql/mysql.sock, abc , xyz); if
While using this code to serialize an object: public object Clone() { var serializer
When using this code (simplified for asking): var rows1 = (from t1 in db.TABLE1
I am using this code to get the background image of a div .
Using this code: var pendingRequest = new Ajax.Request(myUrl, { method: 'post', postBody: soapMsg, contentType:
Using this code with simplehtmldom script ( http://simplehtmldom.sourceforge.net/manual.htm ): function file_get_html() { $dom =

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.