如何使用onmouseout清除mouseenter上显示的数据
How do I clear data shown on mouseenter with onmouseout
当用户悬停在一个图像上时,会出现一个关于该图像的信息框,当我移动到另一个图像时,它们在框内的信息会发生变化,但当我没有图像时,信息框会保留。我无法关闭信息框(即工具提示)。
JS:
var id;
$(document).ready(function () {
$('a').mouseenter(function () {
//var id = $(this).parent().attr('myval');
id = $(this).data('myval');
$.ajax({//create an ajax request to foliobase.php
type: "GET",
//link to the foliobase.php file "?subj" here is the connector
url: "foliobase.php?subj=" + id,
dataType: "html",
success: function (response) {
$("#fillFolio").html(response);
}
});
});
$('a').onmouseleave(function () {
id = $(this).data.display = 'none';
}
});
我怎样才能让信息框在鼠标上消失?我已经尝试了多个测试,但框中甚至没有出现它们,我尝试的最后一个测试在上面的代码中。
$('a').onmouseleave(function () {
id = $(this).data.display = 'none';
}
我在去年才开始使用javascript、jquery等。
提前感谢!!
这是php。
<div class="thumbnails">
<?php
$query = mysqli_query($connection, "select * from portfolio");
print "<ul>";
while ($row = mysqli_fetch_assoc($query)) {print "<li><a href='"javascript:return(0)'" data-myval=".$row['folio_id'] . "><img onClick=preview.src=" . $row['image'] . "name=" . $row['folio_id'] . "src={$row['image']}></a></td></li>";
}
print "</ul>";
?>
</div>
<!--Folio Information-->
<div id="fillFolio">Project Information</div>
我不确定,但尝试使用:
$('a').onmouseleave(function () {
$("#fillFolio").empty();
}
希望这能有所帮助。
$("a").hover(function(){
id = $(this).data('myval');
$.ajax({//create an ajax request to foliobase.php
type: "GET",
//link to the foliobase.php file "?subj" here is the connector
url: "foliobase.php?subj=" + id,
dataType: "html",
success: function (response) {
$("#fillFolio").html(response);
}
});
}, function(){
//im not sure u want to hide or want to just clear your question not clear
$("#fillFolio").empty();
$("#fillFolio").hide();
});
为什么不使用jQuery hover=(mouseenter+mouseleave)
<script type="text/javascript">
var id;
$(document).ready(function () {
$('a').hover(function () {
//var id = $(this).parent().attr('myval');
id = $(this).data('myval');
$.ajax({//create an ajax request to foliobase.php
type: "GET",
//link to the foliobase.php file "?subj" here is the connector
url: "foliobase.php?subj=" + id,
dataType: "html",
success: function (response) {
$("#fillFolio").html(response);
}
});
,function () {
id = $(this).empty();
});
</script>
相关文章:
- 如何通过所选索引(AngularJS)在模态弹出窗口中显示数据
- Angular渲染元素,但不渲染;t显示数据
- 如何在分页事件中突出显示数据表中的单词
- Angular JS和Node路由/布线-仅在页面刷新后显示数据
- MVC中关于表的自定义工具提示-每行显示数据
- Highcharts:根据表单输入动态显示数据
- 重置transform:rotate(),方法是移除并追加在追加和重绘图表后未显示数据的画布
- jqGrid无法显示数据
- 显示数据的最快方式
- 如何从jquery日期和时间选择器中选择和显示数据
- 我的复选框没有't使用的循环来显示数据
- 如何在状态输入ui路由器时立即显示模板,然后当承诺被解决时显示数据
- 车把模板不显示数据
- 如何完成表单后使用 AJAX 重定向并在其他页面上显示数据
- Html5 Web 存储未在第二页中显示数据
- ASP.Net VB - 显示数据折叠样式
- 正确禁止显示数据表中的警告
- 在使用 JS 进行选择时在文本框中显示数据
- 如何使用 C# 和 Angular js 在视图上显示数据
- 在轨道上的 Ruby 文本字段中动态显示数据