立即注冊(cè) 找回密碼

QQ登錄

只需一步,快速開始

鼠標(biāo)移動(dòng)在文字上面,讓其顯示詳細(xì)信息的html代碼

2017-11-20 23:23| 發(fā)布者: 大師兄| 查看: 972| 評(píng)論: 0

摘要: 今天我們來給大家介紹下,關(guān)于鼠標(biāo)移動(dòng)在文字上面,讓其顯示詳細(xì)信息的html代碼一、文字太多,以省略號(hào)結(jié)尾p id="p_0" onmouseover="showTooltip(this);" style="overflow: hidden; text-overflow: ellips ...
今天我們來給大家介紹下,關(guān)于鼠標(biāo)移動(dòng)在文字上面,讓其顯示詳細(xì)信息的html代碼
一、文字太多,以省略號(hào)結(jié)尾


<p id="p_0" onmouseover="showTooltip(this);" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
    ${checkContentTitle}
</p>
二、鼠標(biāo)移動(dòng)在文字上面,彈出浮動(dòng)的div讓其顯示詳細(xì)信息
<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'>把鼠標(biāo)移到我上面看看...</label>  
<div id='tooltip0' style='display:none;border:1px solid gray;background-color:yellow;color:blue;'><p>這是一段文字的詳細(xì)信息</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>

    <!--  標(biāo)題  -->
    <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>


鮮花

握手

雷人

路過

雞蛋

最新評(píng)論

相關(guān)推薦
!jz_fbzt! !jz_lxwm! !jz_gfqqq!

關(guān)于我們|手機(jī)版|小黑屋|地圖|【道勤網(wǎng)】-bmrsportswear.com 軟件視頻自學(xué)教程|免費(fèi)教程|自學(xué)電腦|3D教程|平面教程|影視動(dòng)畫教程|辦公教程|機(jī)械設(shè)計(jì)教程|網(wǎng)站設(shè)計(jì)教程【道勤網(wǎng)】 ( 皖I(lǐng)CP備15000319號(hào)-1 )

GMT+8, 2024-10-23 07:32

Powered by DaoQin! X3.4 © 2016-2063 Dao Qin & 道勤科技

返回頂部