我有 3 个文本框,它们都具有相同的 id,我通过将其放入控制器数组中处理到 ASP 中
I have 3 textboxes, all with the same id's that I process into ASP by bringing it into a controller array
我有一个链接,可以在前 3 个下方添加无限数量的文本框.
I have a link that adds an unlimited number of textboxes below the first 3.
我目前的变更声明:
$('input.#invent').change(function () {
适用于第一个文本框上的更改事件,但是具有相同信息的其他人在更改时不会触发它
works fine for the change event on the first textbox, but the others with the same information do not fire it when changed
当任何 3 个以上的文本框发生更改时,触发更改事件的最佳策略是什么??
What is the best strategy for getting the change event to fire when any of the 3+ textboxes change??
将 ID 为 #invent 的所有三个元素改为一个类(ID 的 必须是唯一的),否则它只适用于第一个元素,比如什么您的情况目前正在发生.
Change all three elements with the #invent ID to a class instead (ID's must to be unique), or it's only going to work for the first element, like what's currently happening in your case.
然后,您可以定位所有具有 .invent 类的元素:
Then, you can target all of the elements that have the .invent class:
$('input.invent').change(function () {
// Here, $(this) refers to the specific element of the .invent class which 'changed'
}):
详细了解 ID 和类选择器之间的区别这里一个>.
Read more about the difference between ID and Class selectors here.
这篇关于多个元素上的一个 jQuery 更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
即使在调用 abort (jQuery) 之后,浏览器也会等待Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在调用 abort (jQuery) 之后,浏览器也会等待 ajax 调用
JavaScript innerHTML 不适用于 IE?JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不适用于 IE?)
XMLHttpRequest 无法加载,请求的资源上不存在“AXMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 无法加载,请求的资
XMLHttpRequest、jQuery.ajax、jQuery.post、jQuery.get 有什么What is the difference between XMLHttpRequest, jQuery.ajax, jQuery.post, jQuery.get(XMLHttpRequest、jQuery.ajax、jQuery.post、jQuery.get 有什么区别
可以使用 xhrFields 将 onprogress 功能添加到 jQuery.Can onprogress functionality be added to jQuery.ajax() by using xhrFields?(可以使用 xhrFields 将 onprogress 功能添加到 jQuery.ajax() 吗?)
显示使用 XHR2/AJAX 下载文件的进度条Show a progress bar for downloading files using XHR2/AJAX(显示使用 XHR2/AJAX 下载文件的进度条)