Hi all,
This is kind of difficult to explain, so I'll paste the function, and explain what it does
function close(r){
if(r !== undefined){
$('#close').attr('name','1');
$('#close').css({
top: 30,
left: 30
});
$('#close').html('First click here');
}else{
switch($('#close').attr('name')){
case '1':
$('#close').attr('name','2');
$('#close').animate({
bottom: 30,
right: 30
},1000);
$('#close').html('Now click here');
break;
case '2':
$('#close').attr('name','3');
$('#close').animate({
bottom: 30,
left: 30
},1000);
$('#close').html('A now click here');
break;
case '3':
$('#close').attr('name','4');
$('#close').animate({
top: 30,
right: 30
},1000);
$('#close').html('And finally click here');
break;
case '4':
$('#close').remove();
break;
}
}
}
If you require explanation, here it goes
- The close function is first called as
close(1)
. This sets the position to top: 30 and left: 30. Note that its position is already set to absolute in the stylesheet. This first part works, and wherever I choose to place it is obeyed. - The #close element has an oclick assigned to
close()
. Each time it is clicked, as you can see, a different action occurs. Everything works fine (i.e. the html and name attribute changes), except for the animation. The #close element remains stationary. - On the last click, the element successfully disappears.
Does anyone have any ideas?
Cheers
Gausie