2

次の例のように、定義された要素に jQuery を使用してクラスを追加することから始まる CSS でアニメーションを定義しました。

jQuery (私は Firefox でテストしています):

$(document).on('click', 'h1 > span:first-child', function(event) {
    $(this).addClass('animate');
    console.log($('h1 > span.animate').length);   // 1 (Element exists)
    console.log($('h1 > span.animate').css('animation')); // Empty string
    console.log($('h1 > span.animate').css('-moz-animation')); // Empty string
    console.log($('h1 > span.animate').css('-webkit-animation')); // undefined of course ;) 
});

CSS アニメーション (正常に動作)

// The animation testen was defined before an is working an assign class to span element
body h1 span.animate {
  -webkit-animation: testen 5s 1;
  -moz-animation: testen 5s 1;
  -ms-animation: testen 5s 1;
  -o-animation: testen 5s 1;
  animation: testen 5s 1;
}

このようなものではなく、常に空の文字列を取得する理由は何ですか?

animation: testen 5s 1;

前もって感謝します

4

1 に答える 1