jquery如何设置jquery DOM名称

jquery如何设置jquery DOM名称,jquery,Jquery,我正在学习jquery并对其进行定制。当我通过在浏览器中查看源代码来检查stackoverflow.com源代码时。我找到了这个: StackExchange.ready(function () { StackExchange.using("postValidation", function () { StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer')

我正在学习jquery并对其进行定制。当我通过在浏览器中查看源代码来检查stackoverflow.com源代码时。我找到了这个:

StackExchange.ready(function () {
        StackExchange.using("postValidation", function () {
            StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer');
        });
如何编写StackExchange.ready及其函数,如StackExchange.question.init、StackExchange.realtime.subscribeToQuestion等

请帮我做点什么-

var yourCustomName=$(文档)

继续-
yourCustomName.ready(函数(){


Stackoverflow具有自定义就绪方法-

StackExchange.ready=function(d){StackExchange.initialized.done(d)};

StackExchange是他们创建的由函数组成的对象

StackExchange {init: function, debug: Object, initialized: Object, ready: function, using: function…}
MarkdownEditor: function (a){var c=a.postfix||"";(j=StackExchange.options.site.isMetaStackOverflow||StackExchange.options.site.isChildMeta)&&(D=StackExchange.options.site.parentUrl||
anonymous: Object
captcha: Object
cardiologist: Object
chatAd: Object
comments: Object
debug: Object
editor: Object
gps: Object
helpers: Object
ifUsing: function (g,h,d){if("undefined"!==typeof d){if(c["u_"+d])return;c["u_"+d]=!0}StackExchange[g]?h():((d=a[g])||(d=a[g]=[]),d.push(h))}
imageUploader: Object
init: function (j){StackExchange.options=j;j.serverTimeOffsetSec=j.serverTime-(new Date).getTime()/1E3;e(j.site.name);$.ajaxSetup({cache:!1});StackExchange.init.createJqueryExtensions();
initialized: Object
inlineEditing: Object
inlineTagEditing: Object
loadJsFile: function (a){return n(k()+a)}
loggedIn: Object
navPrevention: Object
newsletterAd: Object
notify: Object
openid: Object
options: Object
postValidation: Object
prettify: Object
question: Object
ready: function (d){StackExchange.initialized.done(d)}
要查看StackExchange对象,只需在控制台中键入StackExchange。您可以在此处找到StackExchange的代码

Developer tools -> Sources -> cdn.sstatic.net -> Js

要编写这样的函数,您可以

var StackExchange = {
    init: {
        questions: function () {
            console.log("init")
        }
    },
    ready: function () {
        console.log("init")
    },
    debug: function () {
        console.log("init")
    }
}

我能给出的最好的一般建议是“研究一些模式”,比如显示模块模式。

但没有StackExchange=$(文档);在我学习的StackExchange网站中,你可以在这里找到StackExchange的JS
Developer tools->Sources->cdn.sstatic.net->JS
请告诉我他们是在哪里写的?在JS文件还是其他地方?@shailendra他们写在这里
Developer tools->Sources->->cdn.sstatic.net->JS
这个目录下的所有文件中
var Question = function () {
    this.ask = function () {
        // ....
    };
};
window.StackExchange = (function () {
    var question = new Question();
    return {
        // Add more here to your liking
        question: question,
        ready: $(document).ready
    };
}());

StackExchange.ready(function () {
    question.ask();
});