event.target is a DOM node, not a jQuery object, so it does not have jQuery methods
In jQuery, use $(this)which is the jQuery object instead .
I also suggest that you don’t use the target unless you need to.
: DOM, , OPs , IE.
jQuery:
$('body').on('change', 'select', function(event) {
var $sel = $(this),
id = this.id,
val = $(this).val();
if (id.indexOf("couche") >= 0) {
$.ajax({
url: "{{ redir2 }}",
type: "POST",
data: {
ident: id,
value: val,
iscouche: "True"
},
}).done(function(msg) {
if (msg.nothing == 1) {
var what = $sel.closest('tbody')
$(what).find("tr:gt(0)").remove();
} else {
var add = $sel.closest('tr');
var toremove = msg.toremove.split(" ")
for (var i = 0; i < toremove.length; i++) {
if (toremove[i].length > 0) {
jQuery(toremove[i]).remove();
}
}
jQuery(add).after(msg.ret);
}
});
} else {
$.ajax({
url: "{{ redir2 }}",
type: "POST",
data: {
ident: id,
value: val;,
iscouche: "False"
},
}).done(function(msg) {});
}
});
:
$('body').on('change', 'select', function(event) {
var $sel = $(this),
val = this.value,
id = this.id,
isCouche = id.indexOf("couche") != -1;
$.ajax({
url: "{{ redir2 }}",
type: "POST",
data: {
ident: id,
value: val,
iscouche: isCouche ? "True" : "False";
},
}).done(function(msg) {
if (isCouche) {
if (msg.nothing == 1) {
var what = $sel.closest('tbody')
$(what).find("tr:gt(0)").remove();
} else {
var add = $sel.closest('tr');
var toremove = msg.toremove.split(" ")
for (var i = 0; i < toremove.length; i++) {
if (toremove[i].length > 0) {
$(toremove[i]).remove();
}
}
$(add).after(msg.ret);
}
} else {
}
});
});