开发者

Problem with jquery appendTo function

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 abilit开发者_如何转开发y 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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜