Ich habe folgendes NodeJs
Modul:
import $ from 'jquery';
module.exports =() => {
$("#clients-table tbody tr").click(() => {
let $this = $(this);
console.log($this);
console.log($(this));
console.log($(this).attr("class"));
console.log($("#clients-table tbody tr").attr("class"));
console.log("end");
});
}
und mein Browserify
Einstiegspunkt sieht wie folgt aus:
"use strict";
import $ from 'jquery';
import test from './test';
test();
Wenn ich auf das Element klicke, wird das Klickereignis ausgelöst, aber $(this)
ist undefined
. Hier ist das Ergebnis verschiedener console.logs
:
test.js:9 he.fn.init {}
test.js:10 he.fn.init {}
test.js:11 undefined
test.js:12 test
test.js:13 end
Jede Idee, warum?
Mögliche Duplikat [mit jQuery $ (this) mit ES6 Pfeil Funktionen (lexikalischer diese Bindung)] (http tun: // stackov erflow.com/q/27670401/218196) –