JQuery text change when input changes

How can we do as a lower, simple way?

enter image description here?

It is updated when the input changes.

+5
source share
2 answers

Say you had the following HTML:

<input type="text" id="textbox"/>

<span>http://twitter.com/<span id="changeable_text"></span></span>

Your JS will listen to the event keyup.

$('input#textbox').keyup(function() {
   //perform ajax call...
   $('#changeable_text').text($(this).val());
});
+8
source

Just join the event of keyupthis text box and update the span accordingly.

Text box and range

<input type="text" id="txt-url-suffix" />
<div>Your public profile: http://www.twitter.com/<span id="url-suffix" /></div>

And some simple jQuery

var $urlSuffix = $("#url-suffix");
$("#txt-url-suffix").keyup(function() {
    var value = $(this).val();
    $urlSuffix.text(value);
});
+6
source

All Articles