0

最初のスクリプトを使用してロードした後、2 番目のスクリプトが機能しない

これを使用してロードしようとしています

$(document).ready(function() {


$('div.frame ul#main li a').click(function(){

        var toLoad = $(this).attr('href')+' #content';
        $('#content').hide('fast',loadContent);
        function loadContent() {
            $('#content').load(toLoad,'',showNewContent())
        }
        function showNewContent() {
            $('#content').show('normal',hideLoader());
        }
        function hideLoader() {
            $('#load').fadeOut('normal');
        }
        return false;

    });

});

1ページの読み込み後にこれを使用

$(document).ready(function(e) {


    var currentportfolio = $('div#slider ul li:first-child').addClass('show');
    var portfolio = $('div#slider ul li');  
    $('div#slider ul li').not(':first').hide();


    $('.prev, .next').click(function() {
    // Determine the direction, -1 is prev, 1 is next
    var dir = $(this).hasClass('prev') ? -1 : 1;
    // Get the li that is currently visible
    var current = $('div#slider ul li:visible');

    // Get the element that should be shown next according to direction
    var new_el = dir < 0 ? current.prev('li') : current.next('li');

    // If we've reached the end, select first/last depending on direction
    if(new_el.size() == 0) {
        new_el = $('div#slider ul li:'+(dir < 0 ? 'last' : 'first'));
    }

    // Hide them all..
    $('div#slider ul li').hide();
    // And show the new one
    new_el.show();

    // Prevent the link from actually redirecting the browser somewhere
    return false;
});

});

私はjQueryが初めてです。前もって感謝します。

4

1 に答える 1

1

のドキュメントを確認してください.load。jQuery は、部分関数として「コールバック」関数を提供します.load.loadコールバックは基本的に、完了後に実行されるものです。すでに使用しているようです。

http://api.jquery.com/load/

    function showNewContent() {
        $('#content').show('normal',hideLoader());
        additionalStuffToDoAfterLoad();
    }

    function additionalStuffToDoAfterLoad(){
         //all the stuff in section 2 goes here.
    }
于 2012-07-11T01:07:11.453 に答える