我有以下功能, func resizeInputText 工作正常。基本上,当我的应用程序通过 ajax 成功加载数据时,我想调用 resizeAll 。
由于在页面加载后内容被拉出,我试图将我的每个代码包装在 .on 事件中。
它不起作用,有谁知道如何执行此操作或如何使用 ajax 加载的内容调用 .each ?
一如既往的感谢!
function resizeInputText(obj) {
var boxWidth = ($(obj).val().length * 7) + 1;
if (boxWidth <= 30) {
var boxWidth = 30;
} else if (boxWidth >= 250) {
var boxWidth = 250;
}
$(obj).css({width:boxWidth});
}
function resizeAll() {
$("#right-content").on(function () {
$("input:text").each(function () {
resizeInputText(this);
});
});
}