【发布时间】:2013-07-24 10:03:00
【问题描述】:
我尝试在 ul 内容更改时调用 jQuery 函数。
下面是我的代码
JS
jQuery(document).ready(function($) {
$('.ProductList').live('change', function() {
alert('content is changed now');
});
});
HTML
<ul class='ProductList List Clear'>
call jquery function when content change here.
<li></li>
<li></li>
<li></li>
</ul>
建议我一些想法,以便我解决它。
我尝试根据内容更改调用函数,因为我从事 bigcoomerce 定制和大型商务工作,由于访问权限有限,我不允许我访问 ajax 函数,所以我需要这样调用函数。
【问题讨论】:
-
api.jquery.com/change
The change event is sent to an element when its value changes. This event is limited to <input> elements, <textarea> boxes and <select> elements. For select boxes, checkboxes, and radio buttons, the event is fired immediately when the user makes a selection with the mouse, but for the other element types the event is deferred until the element loses focus.所以.change()不适用于无序列表...还有奇怪的警报信息? -
问题是您的 UL 内容如何变化?
-
为什么这么多点赞,这个问题已经被回答过千遍了……
-
@Jalpesh ha,好的,第三方插件不允许您覆盖 ajax 请求。我会说使用像 .ajaxStop() 这样的全局 ajax 方法并在那里检查 UL 内容是否已更改
标签: javascript jquery html