开发者

set value for current elements and dynamically added elements in jquery

I have the following code but it doesn't work

$("body").delegate("textarea", "ready", function () {
    $(this).val("custom value");
});

My intent is s开发者_如何学运维et that value for current elements on the dom and future textareas added dynamically to the page, is there a solution?


.ready is an event that occurs on the document, not when other elements are loaded. Unfortunately there is not a graceful solution to this either. The best suggestion I can make is that after each of your ajax requests complete, to select all textareas and set their values:

// maybe something similar to this.
$(document).ajaxSuccess(function() {
  $('textarea').val('custom value');
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜