Javascript 在脚本中使用动画设置单击功能
除了“动画单击”功能外,其他功能都可以正常工作 我希望在单击时设置背景动画。Javascript 在脚本中使用动画设置单击功能,javascript,jquery,html,Javascript,Jquery,Html,除了“动画单击”功能外,其他功能都可以正常工作 我希望在单击时设置背景动画。 我知道我可以用html做div标记并调用它,但这不是我想要的 有人能告诉我如何在脚本中使用它吗 if (numbers[i] == 1){ $('<div>1</div>').css({ background: "url(img/1.png)", 'background-size': '100% 100%', '
我知道我可以用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)
});
}
if(数字[i]==1){
$('1').css({
背景:“url(img/1.png)”,
“背景大小”:“100%100%”,
“背景重复”:“不重复”
})
.数据('编号',编号[i])
.attr('id'、'card'+数字[i])
.appendTo(“#cardPile”+桩[i])。可拖动({
包含:“#内容”,
堆栈:“#cardpille1 div”,
光标:“移动”,
})
。单击(函数(){
$('1')。设置动画({
高度:'181px',
宽度:'169px',
顶部:'-30',
左:'-20',不透明度:'0.4'
}, 1000)
});
}
任何帮助都将不胜感激。您需要像这样附加div
$('<div>1</div>').animate({
height:'181px',
width:'169px',
top: '-30',
left: '-20',
opacity: '0.4'}
, 1000).appendTo('body');
$('1')。设置动画({
高度:'181px',
宽度:'169px',
顶部:'-30',
左:'-20',
不透明度:“0.4'}
,1000)。附于(“主体”);
您需要像这样附加div
$('<div>1</div>').animate({
height:'181px',
width:'169px',
top: '-30',
left: '-20',
opacity: '0.4'}
, 1000).appendTo('body');
$('1')。设置动画({
高度:'181px',
宽度:'169px',
顶部:'-30',
左:'-20',
不透明度:“0.4'}
,1000)。附于(“主体”);
单击第一个div时,将创建第二个div:
$('<div>1</div>').animate({....
单击第一个div时,将创建第二个div:
$('<div>1</div>').animate({....
谢谢你的回复,但那不做的工作,什么都没有发生。谢谢你的回复,但那不做的工作,什么都没有发生。谢谢你的回复,我也这么想,但这是一个可拖动的拼图,然后你必须点击两次才能拖动。对不起,是的,它工作了,谢谢。我打了第一个选项,第二个选项效果很好:)谢谢你的回复,我也这么想,但这是一个可拖动的拼图,然后你必须点击两次才能拖动。对不起,是的,可以,谢谢。我把第一个选项打成平局,第二个选项效果很好:)