How to update spacing when text is entered into form text field using jquery

I would like to update the range when a value is entered into a text box using jquery. In my form field there is a text field named "userinput" and I have an interval with the identifier "inputval". Any help would be greatly appreciated.

+4
source share
4 answers

UPDATE: although you flagged this as the correct answer, note that you should use the keyup event, not the change or keydown event

$(document).ready(function() { $('input[name=userinput]').keyup(function() { $('#inputval').text($(this).val()); }); }); 
+10
source

Try it. Make sure you understand what is happening here.

 // when the DOM is loaded: $(document).ready(function() { // find the input element with name == 'userinput' // register an 'keydown' event handler $("input[name='userinput']").keydown(function() { // find the element with id == 'inputval' // fill it with text that matches the input elements value $('#inputval').text(this.value); } } 
+1
source
 $(function() { $("input[name=userinput]").keydown( function() { $('#inputval').text(this.value); } ) }) 
+1
source

Try the following: you need to call keyup() again to run the last char:

 $(".editable_input").keyup(function() { var value = $(this).val(); var test = $(this).parent().find(".editable_label"); test.text(value); }).keyup(); 
+1
source

All Articles