domino
domino

Reputation: 7345

jquery function doesn't work after typing in textbox

 $('.quote').live('click', function() {


    var quote = "test";
    $("#msg").append(quote).scrollTop($('#msg')[0].scrollHeight).focus();

 });

This function just copies "test" to the textbox. Since it will be a multi-quote function I used the append() function. It works fine. Even when I focus on the textbox.

BUT when I type any characters in the textbox or break the line it no longer works. Any ideas?

msg - textbox

focus(); isn't also working for some reason.

Upvotes: 0

Views: 75

Answers (1)

Manuel van Rijn
Manuel van Rijn

Reputation: 10315

try:

$("#msg").val(function(index, value) {
    return value + ' ' + quote;
}).scrollTop($('#msg')[0].scrollHeight).focus();

jsfiddle

Upvotes: 2

Related Questions