当FireFox上的mousewheel事件时,e.pageX返回undefined

时间:2017-10-14 01:37:53

标签: javascript jquery mousewheel mouse-pointer

我正试图在鼠标滚轮事件时获得鼠标位置。

这是小提琴。 https://jsfiddle.net/xta2ccdt/7/

purchasePrice = input("Enter purchase price")
purchasePrice = int(purchasePrice)

#Variable declaration for preservation.
month = 1
monthlyPayment = purchasePrice/12
ammountDue = purchasePrice

while month <=12:
    print (month)
    ##This is a condensed way of doing 'month = month + 1'
    month += 1
    ##Again this is a condensed form of 'amountDue = amountDue - monthlyPayment'
    amountDue -= monthlyPayment 
    print ("Monthly payment", monthlyPayment)
    print ("Amount due: ", amountDue)

显示未定义。
这个实现有什么问题?

1 个答案:

答案 0 :(得分:4)

尝试访问e.originalEvent.pageX,这将访问看起来在Firefox中运行正常的vanilla JS事件。

看起来这只是一个jquery v2错误。在你的小提琴中将jquery版本更新为jquery 3后,它也适用于e.pageX

https://jsfiddle.net/xta2ccdt/8/