I have created a keyup() function the code is here
$(document).ready(function() {
var scntDiv = $('#add_words');
var wordscount = 1;
$(document).keyup(function(e) {
var key = (e.keyCode ? e.keyCode : e.which);
if (key === 32) {
wordscount++;
$('.input1').append('<p>stop touching your keyboard</p>');
$('<div class="line">Word ' + wordscount + '<input type="text" class="input' + wordscount + '" value="' + wordscount + '" /><a class="remScnt">Remove</a></div>').appendTo(scntDiv);
i++
return false;
}
});
});
<div id="add_words">
<div class="line">Word 1<input class="input1" type="text" value="1" /></div>
</div>
which is working fine but whenever I press spacebar adding new input field.
the problem is that I wouldn’t able to type long words with space(coming a lot of input field)
eg:- when type “my hello world” shows two input field. Actually I need one extra field.
my question is that is there any option keyup() function working only on first time in the same field
If you know could you help me please
I think this is what you serach for
});
JS Fiddle:
http://jsfiddle.net/pURVS/