How Can I Replace Html Text Dynamically?
I'm adding the text 'I Tot I Taw a Puddy Tat!' to the top of a page with jQuery this way in the ready function: $('#Twitterati').html('
I Tot I Taw a Puddy Tat!
Solution 1:
Try this:
$("#inputQuery").keyup(function(e) {
if(e.keyCode == 13) {
$("#Twitterati h3").html($(this).val());
}
});
Missing a closing bracket here $("#inputQuery" <----
and a extra bracket at last .val())); <----
Solution 2:
Fix this line
v
$("#Twitterati h3").html($("#inputQuery").val());
Use .html()
instead of .val()
for the h3
Solution 3:
You want to set the HTML of the target element. Also, you can use "this" instead of targeting the element by ID again
$("#inputQuery").keyup(function(e) {
if(e.keyCode == 13)
$("#Twitterati h3").html($(this).val());
});
Solution 4:
You are missing closing braket that leads error and replace .val() with .html because you are replacing text not value
$("#Twitterati h3").html($("#inputQuery").val());
but your original was
$("#inputQuery".val()) //MIssing HERE
You can use this also like
$("#Twitterati h3").html($(this).val());
'this' will automatically indicates the inputQuery
Solution 5:
replace "#inputQuery".val()
with
$("#inputQuery").val()
CODE IS:
$("#inputQuery").keyup(function(e) {
if(e.keyCode == 13) {
$("#Twitterati h3").html($("#inputQuery").val());
}
});
Post a Comment for "How Can I Replace Html Text Dynamically?"