alkokarko
alkokarko

Reputation: 85

How to animate text with jquery to slide to the right

So I keep track of right and wrong answers and I want to slide the text from the right of the screen.

Here is what I have, but it doesn't work:

document.getElementById('total').innerHTML = "Number of Right Answers: " + right;
document.getElementById('totalw').innerHTML = "Number of Wrong Answers: " + wrong;
$("#total").show("slide", {
  direction: "right"
}, 2000);
$("#totalw").show("slide", {
  direction: "right"
}, 2000);
<div id="total"></div>
<div id="totalw"></div>

Upvotes: 0

Views: 56

Answers (1)

alessandrio
alessandrio

Reputation: 4370

add in file html:

$('#total').html("Number of Right Answers: " + "right");
$('#totalw').html("Number of Wrong Answers: " + "wrong");
$("#total").show('slide', {direction: 'right'}, 1000);
$("#totalw").show( "slide", {direction: "right" }, 2000 );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.effects.core.js"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.effects.slide.js"></script>
<div id="total"></div>
<div id="totalw"></div>

Upvotes: 1

Related Questions