I'm using DOMNodeInserted
MutationEvent, is any way to select only new inserted elements by using this event?
I have to add class to all inputs when they are inserted to document.
I'm inserting new inputs to form via AJAX request but I can't add it there because this part have to work independently.
You can get the inserted element with ev.target
and check with jQuery's is()
method the tag name.
E.g.:
$(document).on('DOMNodeInserted', function(ev){
var _self = $(ev.target);
if(_self.is('input')) {
_self.addClass('inputClass');
}
});