Reputation: 22820
How can we do like the bottom, the simple way ?
?
it updates when we change the input.
Upvotes: 5
Views: 16943
Reputation: 163318
Say you had the following HTML:
<input type="text" id="textbox"/>
<span>http://twitter.com/<span id="changeable_text"></span></span>
Your JS would listen for the keyup
event.
$('input#textbox').keyup(function() {
//perform ajax call...
$('#changeable_text').text($(this).val());
});
Upvotes: 8
Reputation: 72230
Just attach to the keyup
event of that textbox and update a span accordingly.
The textbox and span
<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);
});
Upvotes: 6