Apply Type Effect to fill input field with variable value with jQuery
Apply Type Effect to fill input field with variable value with jQuery
I was able to copy the value of a hidden field, navigate to another tab and paste it into another input field. I want to apply typewriting for the latter.
$('#send0').click(function()
var user = $('#friend').val();
$("#Profile").removeClass("show");
$('a[href*="Profile"]').removeClass("active").addClass("collapsed");
$('a[href*="Send-Credit"]').addClass("active").removeClass("collapsed");
$("#Send-Credit").addClass("show");
document.getElementById("receiver").setAttribute('value', user);
);
I tried to manipulate below example with no luck. Any idea.
var i = 0;
var user = $('#friend').val();
var speed = 50;
function typeWriter()
if (i < txt.length)
document.getElementById("receiver").setAttribute('value', user.charAt(i));
i++;
setTimeout(typeWriter, speed);
1 Answer
1
One side you are using jQuery for above code and typing effect has not jQuery!
Anyway, You are using setAttribute
to apply value, Use jQuery for the same.
setAttribute
var i = 0;
var txt = 'Lorem ipsum dummy text blabla.';
var speed = 50;
function typeWriter()
if (i < txt.length)
$("#demo").val($("#demo").val()+txt.charAt(i));
i++;
setTimeout(typeWriter, speed);
.myText
width:100%;
padding:15px;
display:block;
font-size:20px
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button onclick="typeWriter()">Click me</button>
<input type="text" id="demo" class="myText" />
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.