0
j = {largeSign: function(a) {
        var b = $(#identity .scorecard"), c = 43, d = 105 - c, e = 800;
        this.animation(b, d, c, e, a)
    },animation: function (a, b, c, d, e) {
        var f = this, g = 1e3, h, i = function() {
             $(".sign", a).each(function(a, f) {
                  h = parseInt(e + $(this).text()), a > 2 && (d += 30), a === 0 || a === 3 ? $(this).animate({backgroundPosition: "0px " + (b * h + c) + "px"}, d * 1.6) : a === 1 || a === 4 ? $(this).animate({backgroundPosition: "0px " + (b * h + c) + "px"}, d * 1.8) : (a === 2 || a === 5) && $(this).animate({backgroundPosition: "0px " + (b * h - b + c) + "px"}, d * 2, function() {
                      $(this).delay(200).animate({backgroundPosition: "0px " + (b * parseInt(e + $(this).text()) + c) + "px"}, 1e3)
                  })
             })
         };
         setTimeout(i, g)
    }}

基本的に、background-positionをアニメーション化して、div.sign内で解析された値で停止させようとしています。

4

7 に答える 7

1

.ready() を使用する

$(document).ready(function(){
  j.largeSign();
});

http://api.jquery.com/ready/

于 2012-04-20T21:11:26.087 に答える
1

jQueryを使用しているようですので、jQueryソリューションは次のとおりです。

$(function() {
    // your code here
});

これは単なる省略形です

$(document).ready(function() {
    // your code here
});
于 2012-04-20T21:11:11.773 に答える
0

あなたはそれをラップすることができます.ready()

jQuery(document).ready(function($) {
  // Code using $ as usual goes here.
});
于 2012-04-20T21:11:14.300 に答える
0

ドキュメントがロードされた後にこれを実行したい場合は、これを試してください:

$(function(){
//put your code here
j = {largeSign: function(a) {...
});

「$(function(){」を使用する方が「$(document).ready」よりも優れていることがわかりました。「$(document).ready」が廃止された場合、すでに「$(function(){..」を使用しています。

于 2012-04-20T21:11:36.400 に答える
0
$(function(){
  j.largeSign.apply(context, arguments);
});

どこ..

contextthis実行時に実際の関数内で参照されるものになります

arguments単一の値、または関数が引数として受け取ることができる値/オブジェクトの配列 (存在する場合) にすることができます。

于 2012-04-20T21:15:47.940 に答える
0

試す

$(document).ready(function() {
   // put all your jQuery goodness in here.
 });
于 2012-04-20T21:16:00.763 に答える
0

コードを次のようにラップします。

$(document).ready(function(){

  // the call goes here

})
于 2012-04-20T21:10:37.563 に答える