gpt4 book ai didi

jquery - 在通过 ajax 加载的输入字段上绑定(bind) jquery 函数

转载 作者:行者123 更新时间:2023-12-01 04:17:08 24 4
gpt4 key购买 nike

我正在使用 jquery ui 日期选择器。在测试页面上它工作正常。

<div><input type="text" name="basic_example_1" id="basic_example_1" value="" />                     </div>      

<script>
$('#basic_example_1').datetimepicker();
</script>

但是如果输入字段是通过ajax加载的,我应该如何放置脚本?我试过这个

$("#basic_example_1").live("click", function(){
$(this).datetimepicker();
});

不工作。感谢任何提示。

最佳答案

在ajax的success函数之后以及附加输入之后调用datetimepicker():

$.ajax({
....
success:function(){
//do your stuff.. append your input which is already done I guess
$('#appendedInputID').datetimepicker(); //id of appended input
}
});

关于jquery - 在通过 ajax 加载的输入字段上绑定(bind) jquery 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13965631/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com