jquery - How can I replace html text dynamically? -


i'm adding text "i tot taw puddy tat!" top of page jquery way in ready function:

$("#twitterati").html("<h3>i tot taw puddy tat!</h3>").append(tweetiepie); 

...but want dynamically replace placeholder text ("i tot taw puddy tat!") contents of text input control:

<input type="text" name="inputquery" id="inputquery" placeholder="enter something" style="display: inline-block;" /> 

...when enter key mashed. how can that?

i tried this:

$("#inputquery").keyup(function(e) {     if(e.keycode == 13) {         $("#twitterati h3").val($("#inputquery".val()));     } }); 

...and this:

$("#inputquery").keyup(function(e) {     if(e.keycode == 13) {         $("#twitterati h3").replacewith($("#inputquery".val()));     } }); 

...but neither 1 did anything, see...

update

this working pretty well, now; want tweets refresh when inputquery val replaces text/caption/heading, too. iow, can change text from, say, "jquery" "html5" tweets i've got displaying remain jquery tweets. how can div refresh?

try this:

$("#inputquery").keyup(function(e) {     if(e.keycode == 13) {         $("#twitterati h3").html($(this).val());     } }); 

missing closing bracket here $("#inputquery" <----
, bracket @ last .val())); <----


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -