In this case, challenge is dom elements are created dynamically for different request and total number of dom elements are not fixed [eg may be 1 or multiple no of rows].
For example table/dom elements are created when there is a response from the web service. There is a save button on the web page but it will enabled only when there is any change on one of the element [change should not be identical to the last value].
Use the .on()
function's event delegation syntax to bind change
event handlers to your inputs. Something like this:
$(document).on('input', 'change', function() {
// enable your 'Save' button
});
There's more information about event delegation in the linked API page, particularly the Direct and delegated events section.
Note that the .on()
function was introduced in jQuery 1.7. If you're using a version prior to that, you can get the same result using the .delegate()
function instead - just switch the first two arguments around.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.