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 textarea
s and set their values:
// maybe something similar to this.
$(document).ajaxSuccess(function() {
$('textarea').val('custom value');
});
精彩评论