-3

I run a page and get this error:

 Uncaught typeerror: object [object Object] has no method 'onmouse'

The code it is referring to is below:

 $('.firsttext').onmouse(function () { $('.textinline.hover').show() });

My guess is that whatever .firsttext is being used on doesn't have an onmouse event but maybe a onClick, but I don't have a .firsttext or a .textinline running on the page. Although it could be in my CSS attached to something somewhere. Not sure how to figure out which method it is talking about.

4

2 回答 2

2

没有“onmouse”之类的事件,即使在纯 JS 中也是如此;也许你的意思是“onmouseover”?请参阅MDN 事件参考jQuery 鼠标事件类别

然后,您需要使用适当的 jQuery 等效项来绑定事件(它不会以“on”开头;例如.mouseover())或使用通用.on()函数(我倾向于认为更清晰) - 或者在早期版本的 jQuery 中,.bind().

于 2013-07-23T13:28:28.080 回答
0

你需要这样写:

$('.firsttext').on('mouseover', function () { $('.textinline.hover').show() });

jQueryon函数将事件处理程序附加到所选元素。http://api.jquery.com/on/

于 2013-07-23T13:24:29.003 回答