jquery没有看到新的

jquery没有看到新的

本文介绍了jquery没有看到新的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 我有一个简单的问题: }); $ (#TuningSelector)。change(function(){ DoSomethingWithTheValue(); }); }); 问题是:当仪器更改时,脚本不再响应TuningSelector更改。像JQuery没有看到新的TuningSelector元素... 我需要在JQuery上调用刷新吗?那么它会看到刷新的DOM?解决方案一般来说,你想使用 on ,以便它将处理程序应用于与选择器匹配的新元素并委托给DOM中的较高元素。 on('change','#control',function(){ DoSomething(); }); $ I am new to JQuery, so bear with me :).I have a simple problem: $(document).ready(function() { $("#instrument").change(function() { $("#tunings").html("<select id=\"TuningSelector>\"[..]</div>"); }); $("#TuningSelector").change(function() { DoSomethingWithTheValue(); }); });Problem is: When instrument has changed, the script doesn't respond anymore to TuningSelector changes. Like JQuery doesn't see the new TuningSelector element...Do I need to call a refresh on JQuery or so? So that it sees the refreshed DOM? 解决方案 Generally you want to use on so that it applies the handler to new elements matching the selector and delegate to a higher element in the DOM.$('body').on( 'change', '#control', function() { DoSomething();}); 这篇关于jquery没有看到新的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-06 08:27