English 中文(简体)
javascript syntax with j Query [duplicate]
原标题:javascript syntax with jQuery [duplicate]
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
What do parentheses surrounding a JavaScript object/function/class declaration mean?
What does this JavaScript/jQuery syntax mean?

这是一个开放的资料来源图书馆。

有些人解释该守则?

(function($){...})(jQuery);

缩略语

这一辛子是什么?

我如何在守则之外打上<条码>。

我的用词是:

$(function() {
    $("#leanModal").leanModal({top:200});
});

$(function(){...});//again what s this syntax?

法典:

(function($) {

    $.fn.extend({

        leanModal: function(options) {

            var defaults = {
                top: 100,
                overlay: 0.5
            }

            options = $.extend(defaults, options);

            return this.each(function() {

                var o = options;

                $(this).click(function(e) {

                    var overlay = $("<div id= lean_overlay ></div>");

                    var modal_id = $(this).attr("href");

                    $("body").append(overlay);

                    $("#lean_overlay").click(function() {
                        close_modal(modal_id);
                    });

                    var modal_height = $(modal_id).outerHeight();
                    var modal_width = $(modal_id).outerWidth();

                    $( #lean_overlay ).css({
                         display :  block ,
                        opacity: 0
                    });

                    $( #lean_overlay ).fadeTo(200, o.overlay);

                    $(modal_id).css({

                         display :  block ,
                         position :  fixed ,
                         opacity : 0,
                         z-index : 11000,
                         left : 50 +  % ,
                         margin-left : -(modal_width / 2) + "px",
                         top : o.top + "px"

                    });

                    $(modal_id).fadeTo(200, 1);

                    e.preventDefault();

                });

            });

            function close_modal(modal_id) {

                $("#lean_overlay").fadeOut(200);

                $(modal_id).css({
                     display :  none 
                });

            }

        }
    });

})(jQuery);
问题回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.