$('#div1').mousedown(function () {this})中的this指向哪里?
代碼如下 希望實現(xiàn)在div1里邊點下并移動鼠標(biāo)顯示鼠標(biāo)坐標(biāo),鼠標(biāo)抬起便停止,下面代碼能正常運行,但是我試著把$('#div1').mousedown(function () {})中的$('#div1')換成this以后卻沒法運行了,請問mousedown里邊回執(zhí)函數(shù)function里邊的this指向哪里的
$('#div1').mousedown(function () {
? ?$('#div1').mousemove(function (i) {
? ? ? ?$('#p1').text("鼠標(biāo)的坐標(biāo)為:"+i.pageX+"," +
? ? ? ? ? ?i.pageY)
? ?})
})
$('#div1').mouseup(function () {
? ?$('#div1').off('mousemove')
})
2017-04-02
$('#div1').mousedown(function () {
? ?$(this).mousemove(function (i) {
? ? ? ?$('#p1').text("鼠標(biāo)的坐標(biāo)為:"+i.pageX+"," +
? ? ? ? ? ?i.pageY)
? ?})
})
$('#div1').mouseup(function () {
? ?$('#div1').off('mousemove')
})
這樣改是可以的,你不是寫成?this.mousemove(function (i)?這樣的了吧
2017-03-15
div