1

除了动画点击功能外,一切正常。

我希望在单击时具有动画背景。
我知道我可以在 html 中做 div 标签并调用它,但这不是我想要的。

谁能告诉我如何在脚本中完成它?

if (numbers[i] == 1){
    $('<div>1</div>').css({
            background: "url(img/1.png)", 
            'background-size': '100% 100%', 
            'background-repeat': 'no-repeat'
        })
        .data( 'number', numbers[i] )
        .attr( 'id', 'card'+numbers[i] )
        .appendTo( '#cardPile' + pile[i] ).draggable({
            containment: '#content',
            stack: '#cardPile1 div',
            cursor: 'move',
        })
        .click(function(){
            $('<div>1</div>').animate({
                height:'181px', 
                width:'169px', 
                top: '-30', 
                left: '-20', opacity: '0.4'
            }, 1000)
        });
}

任何帮助,将不胜感激。

4

2 回答 2

1

当您单击第一个 div 时,您会创建第二个:

$('<div>1</div>').animate({....

也许你想在动画中使用相同的?

$(this).animate({...
于 2012-11-30T12:36:08.323 回答
0

你需要这样append的div

$('<div>1</div>').animate({
      height:'181px',
      width:'169px',
      top: '-30', 
      left: '-20', 
      opacity: '0.4'}
   , 1000).appendTo('body');
于 2012-11-30T12:33:22.453 回答