I'm designing a static HTML page. It has two input fields and a change button.
<form name="formTextBox" method="post">
<span id="departImage">
<img src="images/FlightImg.png">
</span>
<span class="spanInputOne" id="spanInputOneId">
<input type="text" maxlength="5"
class="textBox" id="departTextBox" name="txtDpt" />
</span>
<input type="image" src="images/SwitchMode.png"
class="centerButton" id="changeButton"
onclick="change()" value="change" />
<span id="arrveImage">
<img src="images/FlightImgDown.png">
</span>
<span class="spanInputTwo" id="spanInputTwoId">
<input type="text" maxlength="5"
class="textBox" id="arrivalTextBox" name="txtArr"/>
</span>
</form>
What i wanted to do is, when clicking the change button, the value in text field should swap mean while the text box should move visually to another box position. so i've included css3 animation, javascript as follows
css3
.animation {
position: relative;
animation: swap .5s;
-moz-animation:swap .5s; /* Firefox */
-webkit-animation:swap 1s; /* Safari and Chrome */
}
@-moz-keyframes swap /* Firefox */
{
0% {left:0%; top:0%;}
100% {left:50%; top:0%;}
}
@-webkit-keyframes swap /* Chrome and Safari */
{
0% {left:0%; top:0%;}
100% {left:50%; top:0%;}
}
.animationOne {
position: relative;
animation: swapOne .5s;
-moz-animation:swapOne .5s; /* Firefox */
-webkit-animation:swapOne .5s; /* Safari and Chrome */
}
@-moz-keyframes swapOne /* Firefox */
{
0% {right:0%; top:0%;}
100% {right:48%; top:0%;}
}
@-webkit-keyframes swapOne /* Chrome and Safari */
{
0% {right:0%; top:0%;}
100% {right:48%; top:0%;}
}
Javascript
function change() {
var depart=document.getElementById("departTextBox").value;
var arrive=document.getElementById("arrivalTextBox").value;
$("span:eq(1)").addClass("animation");
$("span:eq(3)").addClass("animationOne");
document.formTextBox.txtDpt.value = arrive;
document.formTextBox.txtArr.value = depart;
}
The text boxes are animating well as expected. But text box values are disappeared after the animation is done. Could some one help me...