5

How can we do like the bottom, the simple way ?

enter image description here ?

it updates when we change the input.

2 Answers 2

8

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());
});
Sign up to request clarification or add additional context in comments.

1 Comment

or use the .keyup, .keypressed functions if you want changes to happen as they are typed, the .change will only fire once the focus is lost.
6

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);
});

1 Comment

thanks!, yeah i just cant figure the logic, btw after ive search the jquery docs i found keyup. thanks again marko

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.