鼠标移动在文字上面,让其显示详细信息

8 篇文章 0 订阅
1 篇文章 0 订阅

鼠标移动在文字上面,让其显示详细信息

一、文字太多,以省略号结尾

<p id="p_0" onmouseover="showTooltip(this);" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
    ${checkContentTitle}
</p>

二、鼠标移动在文字上面,弹出浮动的div让其显示详细信息

<script>  
function showTooltip(target) {  
    document.getElementById(target.id.replace(/^label/,'tooltip')).style.display = 'block';  
}  
function hideTooltip(target) {  
    document.getElementById(target.id.replace(/^label/,'tooltip')).style.display = 'none';  
}  
</script>  

<label onmouseover='showTooltip(this);' onmouseout='hideTooltip(this);' id='label0'>把鼠标移到我上面看看...</label>  
<div id='tooltip0' style='display:none;border:1px solid gray;background-color:yellow;color:blue;'><p>这是一段文字的详细信息</p></div>  

三、完整的JSP代码

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="org.jeecgframework.core.util.ResourceUtil"%>
<% 
    String mobile_home_url = ResourceUtil.getConfigByName("letv.gcr.mobile.home.url");
%>
<script>
function showTooltip(target) {
    document.getElementById(target.id.replace(/^p_/,'div_tip_')).style.display = 'block';
    document.getElementById("div_title").style.display = 'none';
}
function hideTooltip(target) {
    document.getElementById(target.id.replace(/^p_/,'div_tip_')).style.display = 'none';
    document.getElementById("div_title").style.display = 'block';
}
</script>
<div class="nav">
    <div class="return"></div>

    <!--  标题  -->
    <div id="div_title" class="headline">
        <p id="p_0" onmouseover="showTooltip(this);" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
            ${checkContentTitle}
        </p>
        <span>${checkContentNum}</span>
    </div>
    <div id="div_tip_0" style="display:none;" class="headline">
        <p id="p_0" onmouseout="hideTooltip(this);">
            ${checkContentTitle}
        </p>
        <span>${checkContentNum}</span>
    </div>

    <div class="home"></div>
</div>

<script>
    var historyBack = "${historyBack}";
    var searchForm = "${SearchForm}"
    var returnUrl = "${returnUrl}";
    $(".return").on("click",function() { // 返回
        if(historyBack == "true") { // historyBack为true
            history.back(-1);
        } else {
            if(searchForm==null||searchForm=="") { // searchForm为空
                if(returnUrl==null || returnUrl=="") { // returnUrl为空
                    location.href=document.referrer;
                }else{ // returnUrl非空
                    var locationUrl = ROOF.Utils.projectName() + returnUrl;
                    window.location.href = locationUrl;
                }
            } else { // searchForm非空
                if(returnUrl==null || returnUrl=="") { // returnUrl为空
                    location.href=document.referrer;
                }else{ // returnUrl非空
                    $("#"+searchForm).attr("action", ROOF.Utils.projectName() + returnUrl);
                    $("#"+searchForm).submit();
                }
            }
        }
    });

    $(".home").on("click",function() { // 主页
        var locationUrl = "<%=mobile_home_url%>";
        window.location.href = locationUrl;
    });
</script>
  • 3
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值