gpt4 book ai didi

在另一个 div 上显示 div 文本的 jquery 错误

转载 作者:行者123 更新时间:2023-11-28 06:04:13 25 4
gpt4 key购买 nike

在我的个人元素中,我试图将鼠标悬停在图像功能上,该图像具有一个标记为文本的 div 以显示在#showHere div 上,我认为我正确实现了它,但没有任何结果并且很难调试它没有任何显示

html

<div id="content">
<div id="content-left">
<div id="showHere"></div>
</div>

<div id="content-right">

<div class="item">
<img src="guns/Rusty.png" />
<div class="text"> rusty </div>
</div>
</div>
</div>

CSS

    .container{
margin-left: 0;
margin-right: 0;
padding:0 0 0 0;
width: 100%;
}


#content{

overflow: auto;
background-color:#FFFFFF;
margin-left: 0;
margin-right: 0;
}

#content-left{
color: #FFFFFF;
float:left;
background-color:#333333;
width: 25%;
height = 300px;
width = 50px;
}

#content-right{
color: #FFFFFF;
float:right;
background-color:#666666;
width: 75%;
height = 300px;
width = 50px;
}
.text{
display: none;
}

#showHere{
background-color: white;
}

J查询/javascript

$(".item").hover(function () {
"use strict";
var data = $(this).find(".text").html();
$("#showHere").hide().stop().html(data).fadeIn();
}, function () {
"use strict";
$("#showHere").fadeOut();
});

最佳答案

Your code works fine如果你确定它在 DOM is ready 之后执行.你也有一些像 height=50px 这样的样式在 css 中应该是 height:50px

$(function() {
$(".item").hover(function() {
"use strict";
var data = $(this).find(".text").html();
$("#showHere").hide().stop().html(data).fadeIn();
}, function() {
"use strict";
$("#showHere").fadeOut();
});
});
.container {
margin-left: 0;
margin-right: 0;
padding: 0 0 0 0;
width: 100%;
}

#content {
overflow: auto;
background-color: #FFFFFF;
margin-left: 0;
margin-right: 0;
}

#content-left {
color: #FFFFFF;
float: left;
background-color: #333333;
width: 25%;
height: 300px;
width: 50px;
}

#content-right {
color: #FFFFFF;
float: right;
background-color: #666666;
width: 75%;
height: 300px;
width: 50px;
}

.text {
display: none;
}

#showHere {
background: red;
border: 1px solid;
height: 50px;
width: 200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="content">
<div id="content-left">
<div id="showHere"></div>
</div>

<div id="content-right">

<div class="item">
<img src="guns/Rusty.png" />
<div class="text">rusty</div>
</div>
</div>
</div>

关于在另一个 div 上显示 div 文本的 jquery 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36563233/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com