Javascript 为什么我的jquery对象正在更改上下文?

Javascript 为什么我的jquery对象正在更改上下文?,javascript,jquery,jquery-context,Javascript,Jquery,Jquery Context,我正在比较mousedown事件中的两个元素,但由于上下文属性,它们为false: console.log(this, opt.selectedNode); [circle, prevObject: x.fn.x.init[1], context: undefined, jquery: "2.0.3", constructor: function, init: function…] [circle, prevObject: x.fn.x.init[3], context: document, j

我正在比较mousedown事件中的两个元素,但由于上下文属性,它们为false:

console.log(this, opt.selectedNode);
[circle, prevObject: x.fn.x.init[1], context: undefined, jquery: "2.0.3", constructor: function, init: function…]
[circle, prevObject: x.fn.x.init[3], context: document, jquery: "2.0.3", constructor: function, init: function…]
这就是我在mousedown上所做的:

$("circle").ondrag({
    start:function(){
        //this is a jQuery object
        console.log(this==opt.selectedNode); //true the first time, false the second time it's executed
        console.log(this[0]==opt.selectedNode[0]); //always true
        if (this==opt.selectedNode) { //select other node
            $(".selectedNode").removeNSClass("selectedNode");
            if (!point.isFirst()) {
                opt.selectedNode = $("circle").bydata('point',pointarray[pointarray.indexOf(point)-1]).addNSClass("selectedNode"); //if there is a node before
            } else if (!point.isLast()) {
                opt.selectedNode = $("circle").bydata('point',pointarray[pointarray.indexOf(point)+1]).addNSClass("selectedNode"); //if there is a node after
            } else opt.selectedNode = null; //last point, select nothing
        }
    }
});

为什么上下文发生了变化?

一个jQuery对象不等于另一个,即使它们包含相同的DOM元素,它们也是两个不同的对象,但是比较普通JS DOM元素会起作用,但它们应该是相同的。因此每个选择器返回不同的对象?事实上->但是DOM节点不是普通对象,因此,它们可以进行比较->