2011-07-20 16 views
-1

私は2つのレディ機能()スクリプトを持って、私を助けるために、コードを再配置し、誰かfile..canヘッダに保つために、これをどのように組み合わせるか,,, pllzスクリプトエラー準備完了機能()?

1)

<script type="text/javascript"> 

$(document).ready(function() { 

    //Get the height of the first item 
    $('#mask').css({'height':$('#panel-1').height()}); 

    //Calculate the total width - sum of all sub-panels width 
    //Width is generated according to the width of #mask * total of sub-panels 
    $('#panel').width(parseInt($('#mask').width() * $('#panel div').length)); 

    //Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same) 
    $('#panel div').width($('#mask').width()); 

    //Get all the links with rel as panel 
    $('a[rel=panel]').click(function() { 

     //Get the height of the sub-panel 
     var panelheight = $($(this).attr('href')).height(); 

     //Set class for the selected item 
     $('a[rel=panel]').removeClass('selected'); 
     $(this).addClass('selected'); 

     //Resize the height 
     $('#mask').animate({'height':panelheight},{queue:false, duration:500});   

     //Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor 
     $('#mask').scrollTo($(this).attr('href'), 800);  

     //Discard the link default behavior 
     return false; 
    }); 

}); 
</script> 

2)

<script type="text/javascript"> 
$(document).ready(
     function(){ 
      $('#testim').innerfade({ 
       animationtype: 'slide', 
       speed: 750, 
       timeout: 4000, 
       type: 'random', 
       containerheight: '102px' 
      }); 

    }); 

    //Get the height of the first item 
    $('#mask').css({'height':$('#panel-1').height()}); 

    //Calculate the total width - sum of all sub-panels width 
    //Width is generated according to the width of #mask * total of sub-panels 
    $('#panel').width(parseInt($('#mask').width() * $('#panel div').length)); 

    //Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same) 
    $('#panel div').width($('#mask').width()); 

    //Get all the links with rel as panel 
    $('a[rel=panel]').click(function() { 

     //Get the height of the sub-panel 
     var panelheight = $($(this).attr('href')).height(); 

     //Set class for the selected item 
     $('a[rel=panel]').removeClass('selected'); 
     $(this).addClass('selected'); 

     //Resize the height 
     $('#mask').animate({'height':panelheight},{queue:false, duration:500});   

     //Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor 
     $('#mask').scrollTo($(this).attr('href'), 800);  

     //Discard the link default behavior 
     return false; 
    }); 

}); 
</script> 

私はこの1 progoramように保つ修正方法,,、実行中の1されていない,,,,

+0

あるこのjQueryのように見える作るところ右の機能を自分の中にコードをコピー&ペーストすることができますと仮定しますか? – mschonaker

+0

質問をより明確にしてください。 –

答えて

1

私は私はあなたが求めているものを理解していないが、あなたがしたい場合はあなたのコードを一つの準備ブロックに減らしてから、各準備ブロックのコードをそれ自身の関数に入れてください(準備ブロックはありません)。次に、これらの2つの機能を呼び出す準備完了ブロックを1つ用意します。 、そして、

$(document).ready(function() { 
    Init1(); 
    Init2(); 
}); 

function Init1() { 
    // copy code here 
} 

function Init2() { 
    // copy code here 
} 

$(document).readyなし)Init1()Init2()と呼ばれる関数に既存の準備ができてブロックを移動:

ただ1つの準備のブロックを作ります。私はあなたが何が起こるのか知っているように、より良いよりI.

+0

はい、私は1つの準備ブロックで2つの関数を呼び出すのが好きですが、plzコードを並べ替えることができます... – besto

+0

私は私の答えに例を追加しました。 – jfriend00

+0

申し訳ありませんが、まったくJavaスクリプトコードに精通していません...私はこのことを知っていません。 – besto

0
$(document).ready(
     function(){ <<<<<<<<<<< delete 
      $('#testim').innerfade({ 
       animationtype: 'slide', 
       speed: 750, 
       timeout: 4000, 
       type: 'random', 
       containerheight: '102px' 
      }); 

    }); <<<<<<<<< delete 

が、それはこの

$(document).ready(
    $('#testim').innerfade({ 
     animationtype: 'slide', 
     speed: 750, 
     timeout: 4000, 
     type: 'random', 
     containerheight: '102px' 
    }); 
関連する問題