我想通过jQuery使用.queue()
功能排队一些更改。我可以看到'背景黄色'和'边界变成橙色',但我没有看到该段的移位!请帮助它为什么不向左移动250px! (我已按照评论为“段落”添加了“position:relative”)一个简单的程序中的队列功能问题
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('#but1').click(function() {
$('p').queue(function() {
$(this).css('background','yellow');
$(this).css('border', '3px solid orange');
$(this).animate({ left: '250px' });
});
});
});
</script>
</head>
<body>
<button id=but1>Click Me! </button>
<p id=para1 style="position:relative;">This is a paragraph.</p>
</body>
</html>
后来,我试了这个脚本;仍然不起作用,现在我甚至无法在段落中看到更改2,即“background:yellow”和“border:orange”。
<script>
$(document).ready(function(){
$('#but1').click(function(){
$('p')
.queue('alpha',function(){
$(this).css('background','yellow');
})
.queue('alpha',function(){
$(this).css('border','3px solid orange');
})
.queue('alpha',function(){
$(this).animate({left:'250px'},1500});
})
.dequeue('alpha');
});
});
</script>
'左:250像素;'..应该是'留下:“250px'' – 2015-04-17 09:17:48
你读过[文档](https://api.jquery.com/queue/#queue-queueName-callback)关于'.queue()'的用法? – Regent
是的,丽晶酒店;更好的运行示例将不胜感激。 – Deadpool