javascript - Smooth transitions/animations of input field values from jQuery arrays -


hey, taking time assist!

i have text-based input field , button. i've managed make value of text field change @ click of button, , cycle through multiple values on loop using jquery.

however, i'm looking try , create smoother transition between changing values, @ present, change instantaneously. if able fade-in/out, super.

but, if text field content somehow transition downwards, new value transitioning above last, perfect!

i'm competent html , css, have basic knowledge of javascript/jquery, if point me in right direction, or @ least tell me whether or not i'm looking doable, i'd grateful!

i'll include code below. also, here's codepen of said code see have working @ present: http://codepen.io/anon/pen/mwzwqy

html code

<form class="introduction_container">     <input class="input" type="text" readonly value="values go here..."/>     <input class="button" type="button" value="click"/> </form> 

jquery code

$(document).ready(function() {     var content = ["hi there, i'm value.", "oh, hey, me too!", "when grow up, i'm gonna placeholder."];     var x = 0;      $(".button").click(function() {         $(".input").val(content[x]);         x = (x + 1) % content.length;     }); }); 

here example multiple clicks , overlay element:

var content = ["hi there, i'm value.", "oh, hey, me too!", "when grow up, i'm gonna placeholder."];      var x = 0;        $(".button").click(function() {            var input = $('.input');      var input2 = $('<input />', {              css: {                  position : 'absolute',                  top      : input.position().top,                  left     : input.position().left,                  height   : input.height(),                  width    : input.width()              }          });            input.val(content[x]).parent().append(input2);      input2.fadeout('slow');      x++;  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>  <form class="introduction_container">      <input class="input" type="text" readonly value="values go here..."/>      <input class="button" type="button" value="click"/>  </form>


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -