0

I have several textareas on my page and I use jquery focus function to clear the textarea when someone clicks it. Here is the code:

$("textarea.text").focus(function() {
    if( $(this).attr("has_desc") == "false" ) {
        $(this).val("");
        $(this).attr("has_desc", "true");
    }
});

The user has the ability to dynamically add new textareas and I use appendTo function to add new one. The problem is that the above code doesn't work for the appended textareas! The HTML code is exactly the same as for the forms that aren't added dynamically! Can anyone please tell what is the problem?

1 Answer 1

2

.focus will not work for dynamically created elements. You could use .live('focus', function() ...

Sign up to request clarification or add additional context in comments.

1 Comment

No prob. You should accept the answer if it's the right one you're looking for. :)

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.