开发者

On jQuery UI's demo web page what is the source code for the "View Source" link?

开发者 https://www.devze.com 2022-12-30 05:18 出处:网络
Middle way down on jQuery UI\'s de开发者_开发知识库mo web page here what is the source code for the \"View Source\" link that opens and close a window of the source code?This is just a function in the

Middle way down on jQuery UI's de开发者_开发知识库mo web page here what is the source code for the "View Source" link that opens and close a window of the source code?


This is just a function in their script that hides and shows the source div:

if ($('#demo-source').length == 0) {
    $('<div id="demo-source"><a href="#" class="source-closed">View Source</a><div><pre><code></code></pre></div></div>').insertAfter('#demo-notes');
    $('#demo-source').find("> a").click(function() {
        $(this).toggleClass("source-closed").toggleClass("source-open").next().toggle();
        return false;
    }).end().find("> div").hide();
}
$('#demo-source code').empty().text(source);

You can view the full script here, it grabs the code via ajax ($.get() of the current page, or when you click a demo link on the right, grabs that one), formats it for display, then passes it into that function to insert a "view source" div/link at the right place in the page.

0

精彩评论

暂无评论...
验证码 换一张
取 消