当前位置:网站首页>Uncaught TypeError: $(...).onmouseenter is not a function js错误,解决办法:
Uncaught TypeError: $(...).onmouseenter is not a function js错误,解决办法:
2022-07-26 03:19:00 【清风亦思雨】
想用js实现一个鼠标悬停和移出,用的jQuery,调用的函数是onmouseenter,结果报错Uncaught TypeError: $(...).onmouseenter is not a function。

网上大多是说是jQuery版本问题,我的版本是1.12,版本不算太低,但是也是报错。
还有的说通过bind()进行绑定,我也是未解决。
其实原因极其可笑,我在此记录一下:mouseover是Jquery的,onmouseover是JavaScript的。
就像.click()事件一样,js是onclic(),jQuery是click()。
这样解决就很简单,用原生js配合jQuery来写:
原本的报错代码:
$('# ').onmouseenter(function () {
$('# ').css('display','none');
$('# ').css('display','block');
})
$('# ').onmouseout(function () {
$('# ').css('display','none');
$('# ').css('display','block');
})后来的正确代码(去掉on):
$('# ').mouseenter(function () {
$('# ').css('display','none');
$('# ').css('display','block');
})
$('# ').mouseout(function () {
$('# ').css('display','none');
$('# ').css('display','block');
})边栏推荐
- 【虚拟化】查看vCenter和ESXi主机的Log日志文件
- Offline data warehouse from 0 to 1-stage II software installation
- PXE高效批量网络装机
- Tf.constant usage
- canvas——绘制曲线——挂钟,饼图,五角星
- UDP和TCP可以使用同一个端口吗?
- What are the methods of array sorting in JS
- DDD landing is called an advanced
- sersync/lsync实时同步
- Canvas -- draw curve -- wall clock, pie chart, five pointed star
猜你喜欢

图解LeetCode——5. 最长回文子串(难度:中等)

Istio三之VirtualService、Gateway、DestinationRule配置使用

Leetcode · daily question · sword finger offer | | 115. reconstruction sequence · topological sorting

Use eventlog analyzer for log forensics analysis

Sentinel vs Hystrix 到底怎么选?

LeetCode·

Use Anaconda to configure the tensorflow of GPU Version (less than 30 series graphics cards)

Opencv 以指定格式保存图片

canvas——绘制文本——饼图的修改

sersync/lsync实时同步
随机推荐
2022-07-21 study notes of group 4 self-cultivation class (every day)
Easyexcel sets row hiding to solve the problem of sethidden (true) invalidation
Opencv 以指定格式保存图片
Pit trodden when copying list: shallow copy and deep copy
Dataframe sorting: datetime format splitting; Delete a specific line; Group integration.
大厂面试都面试些啥,看了不亏(一)
【尤里复裂人】带你轻松理解——深拷贝和浅拷贝
如何正确计算 Kubernetes 容器 CPU 使用率
Get twice the result with half the effort: learn the web performance test case design model
Why did Mr. Cao, a productionist in the field of high-end tea, choose Ruifeng L6 max?
What are the methods of array sorting in JS
Usage of tf.variable() function in tensorflow
Unity quickly builds urban scenes
Canvas -- draw curve -- wall clock, pie chart, five pointed star
Sentinel vs Hystrix 到底怎么选?
Opencv saves pictures in the specified format
els 回调函数、退出消息
Alibaba Sentinel - cluster traffic control
【虚拟化】查看vCenter和ESXi主机的Log日志文件
How to correctly calculate the CPU utilization of kubernetes container