I am trying to queue some of the changes by jQuery using the .queue()
functionality. I can see the 'background yellow' and 'border turning orange' but I dont see shifting of the paragraph! Kindly help why its not moving leftwise by 250px! (I've added "position:relative" for "paragraph" as per the comments)
<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>
Later on, I tried this script; still doesn't work, and now I cannot see even earlier 2 changes in paragraph, viz., "background:yellow" and "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>