Jquery 在CSS中悬停不起作用时如何显示隐藏内容
我做错了什么?我来自 我的代码:Jquery 在CSS中悬停不起作用时如何显示隐藏内容,jquery,html,css,show-hide,Jquery,Html,Css,Show Hide,我做错了什么?我来自 我的代码: #txtleeft{ 宽度:25%; 浮动:左; 左缘:7%; } #txtleet.content{ 显示:无; } #TXTMIDLE{ 浮动:左; 宽度:35%; } #txtright{ 浮动:左; 宽度:25%; 保证金权利:7%; } #txtright.content{ 显示:无; } $(文档).ready(函数(){ $(“.content1”).on('hover',function(){ $(“.content”).css(“显示”、“块
#txtleeft{
宽度:25%;
浮动:左;
左缘:7%;
}
#txtleet.content{
显示:无;
}
#TXTMIDLE{
浮动:左;
宽度:35%;
}
#txtright{
浮动:左;
宽度:25%;
保证金权利:7%;
}
#txtright.content{
显示:无;
}
$(文档).ready(函数(){
$(“.content1”).on('hover',function(){
$(“.content”).css(“显示”、“块”);
});
});
左图
左隐藏
中间内容
右隐藏
您的代码似乎工作正常
见
请将jquery的
更改如下:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
更新
如果您试图实现,例如:在悬停时显示div,然后在未悬停时隐藏它,那么您可以使用jquerymouseover
和mouseout
函数来实现
看看这个
修改后的脚本会是这样的
$(document).ready(function () {
$(".content1").mouseover(function() {
// show the element
$(".content").css("display", "block");
});
$(".content1").mouseout(function(){
// show the element
$(".content").css("display", "none");
});
});
在chrome中工作正常。firefox中有控制台错误吗?好的,谢谢,它现在也可以作为代码片段工作了。。。但在我的页面上,它说:ReferenceError:$未在第$(document).ready(function())行定义{尝试将jquery的
更改如下:
查看错误通常发生在jquery未正确加载时..尝试下载jquery并使用..或尝试使用我在上一篇评论中提到的脚本我以另一种方式获得了它,但记不起代码中的错误…再次感谢!我不确定这是否正确是允许的,但我会直截了当地问:当我把鼠标从div上移开时,内容消失了,我该怎么做?这是你想要实现的吗?
$(document).ready(function () {
$(".content1").mouseover(function() {
// show the element
$(".content").css("display", "block");
});
$(".content1").mouseout(function(){
// show the element
$(".content").css("display", "none");
});
});