How do I output the contents of the input without duplicating?

0 like 0 dislike
4 views
Hi all.

I trace event input "input keyup", for that would lead immediately to the screen to filter blocks data which the user entered. But when I try to bring a definitive version of what the user entered (using a click), I'm going through duplication.

Events:

$('#searchPermitted').on('input keyup', function (e) { //... addLiBlocked(); }


Trading on the screen:

addLiBlocked function() { $('.select_lists-choose-blocked').click(function () { $('#select_left ul') .append(''+ $('#searchPermitted').val() + ''); }) }


5ae102a85a9ef803206529.jpeg
by | 4 views

1 Answer

0 like 0 dislike
The standard approach is to use a timer between clicks.

var timeBetweenTypes = 700, // time between clicks 700мс myTimer; // timer //start the timer while firing keyup $('#searchPermitted').on('input keyup', function(){ clearTimeout(myTimer); if ($('#searchPermitted').val()) { myTimer = setTimeout(typeEnd, timeBetweenTypes); } }); // believe that entering text in input over function typeEnd () { $('#textAppender') .append(''+ $('#searchPermitted').val() + ''); }


\rhttps://codepen.io/anon/pen/MGedzZ
by

Related questions

110,608 questions
257,186 answers
0 comments
33,932 users