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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:00:43+00:00 2026-06-16T11:00:43+00:00

I have the following code, but I’m still pretty new to jQuery and I’m

  • 0

I have the following code, but I’m still pretty new to jQuery and I’m pretty sure this is messy code that can be made shorter or maybe use less variables to create a better dynamic plugin. I’m trying to experiment with different types of logic. Here’s the code.

$.pluginName = (function () {
    $(function () {
        var message = "Hello World!";
        var animSpeed = 300;
        var animType = 'fadeIn';
        var icon = "pin";
        var btnText = "Purchase";
        var btnColor = "pink";
        var btnLink = 'http://www.google.com';
        var content = '<div id="mn_close" class="light"></div>' + '<div id="mn_border"></div>' + '<i class="icon-' + icon + '"></i>' + '<span class="mn_message">' + message + '</span>' + '<a href="' + btnLink + '" class="button ' + btnColor + '">' + btnText + '</a>';
        $("#mn_close").live("click", function () {
            $('.mn_bar').animate({
                top: '-50'
            }, animSpeed, function () {});
        });
        $(".mn_bar").append(content);
        $(function () {
            $(".mn_bar").addClass("animated");
            $(".mn_bar").addClass(animType);
        })
    })
})(jQuery);

Any tips on how to pass these variables in to options that the user can change dynamically from a HTML source? I’m not expecting detailed answers, but I’d appreciate any help passed on.

EDI: JS Fiddle with CSS & HTML.

http://jsfiddle.net/QjFnf/8/

Thanks in advance!

  • 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-16T11:00:44+00:00Added an answer on June 16, 2026 at 11:00 am

    See if this helps:

    (function( $ ){
    
      var _defaults = {
        message = 'Hello World!',
        animSpeed = 300,
        animType = 'fadeIn',
        icon = 'pin',
        btnText = 'Purchase',
        btnColor = 'pink',
        btnLink = 'http://www.google.com'
      };
    
      $.pluginName = function( opts ) {
    
        var o = $.extend( {}, _defaults, opts )
          , $bar = $('.mn_bar').addClass('animated '+ animType)
          , $close = $('<div id="mn_close" class="light"/>')
          , $icon = $('<i class="icon-"'+ o.icon +'></i>')
          , $message = $('<span class="mn_message">'+ o.message +'</span>')
          , $link = $('<a href="'+ o.btnLink +'" class="button "'+ o.btnColor +'>'+ o.btnText +'</a>');
    
        $close.click(function(){
          $bar.animate({ top: '-50px' }, animSpeed );
        });
    
        $bar.append( $bar, $close, $icon, $message, $link );
    
      };
    
    })( jQuery );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have following code for moving 4 picture around circular way,but it can rotate
I have the following code (in this case for two images - but in
I have the following code. but it causes exception. using (var context = new
hiya, i have the following code but when i try and create a new
I have the following code but I am getting an exception that a smtp
I have the following code but I get an error on this line userSpinner.setAdapter(adapter);
I have the following code but I am unsure why my array is still
I have the following code but the clear timeout doesn't work and I can't
I have the following code but still have to type full path to use
I have the following code but can't compile it because I have a Type

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.