日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

显示内容长时,显示部分内容,鼠标移入显示全部内容

發(fā)布時間:2025/4/16 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 显示内容长时,显示部分内容,鼠标移入显示全部内容 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

實現(xiàn)思想:

??在頁面內(nèi)放入一個Div,?調(diào)用lable的onMouseover,onMouseout 事件,然后用JS去實現(xiàn)顯示部分內(nèi)容在原有位置還是顯示全部內(nèi)容在Div中。

??? 后臺代碼:  

?

????string?answer?=?e.Row.Cells[10].Text;
??????????????????????????????
if?(answer.Length?>?5)
??????????????????????????????{
????????????????????????????????????????????????????????e.Row.Cells[
10].Text?=?string.Format("<label?onMouseover=\"ddrivetip('{0}','#FFFFE1',?300)\"?onMouseout='hideddrivetip()'>{1}...</label>",?answer,?answer.Substring(0,?5));

?

前臺代碼:

?

<div?id="dhtmltooltip"??style="width:550px?"></div>
<script?type="text/javascript">
var?offsetxpoint=0?//Customize?x?offset?of?tooltip
var?offsetypoint=20?//Customize?y?offset?of?tooltip
var?ie=document.all
var?ns6=document.getElementById?&&?!document.all
var?enabletip=false
if?(ie||ns6)
var?tipobj=document.all??document.all["dhtmltooltip"]?:?document.getElementById??document.getElementById("dhtmltooltip")?:?""
function?ietruebody(){
return?(document.compatMode?&&?document.compatMode!="BackCompat")??document.documentElement?:?document.body
}
function?ddrivetip(thetext,?thecolor,?thewidth){
if?(ns6||ie){
if?(typeof?thewidth!="undefined")?tipobj.style.width=thewidth+"px"
if?(typeof?thecolor!="undefined"?&&?thecolor!="")?tipobj.style.backgroundColor=thecolor
tipobj.innerHTML
=thetext
enabletip
=true
return?false
}
}
function?positiontip(e){
if?(enabletip){
var?curX=(ns6)?e.pageX?:?event.clientX+ietruebody().scrollLeft;
var?curY=(ns6)?e.pageY?:?event.clientY+ietruebody().scrollTop;
var?rightedge=ie&&!window.opera??ietruebody().clientWidth-event.clientX-offsetxpoint?:?window.innerWidth-e.clientX-offsetxpoint-20
var?bottomedge=ie&&!window.opera??ietruebody().clientHeight-event.clientY-offsetypoint?:?window.innerHeight-e.clientY-offsetypoint-20
var?leftedge=(offsetxpoint<0)??offsetxpoint*(-1)?:?-1000
if?(rightedge<tipobj.offsetWidth)
tipobj.style.left
=ie??ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px"?:?

window.pageXOffset
+e.clientX-tipobj.offsetWidth+"px"
else?if?(curX<leftedge)
tipobj.style.left
="5px"
else
tipobj.style.left
=curX+offsetxpoint+"px"
if?(bottomedge<tipobj.offsetHeight)
tipobj.style.top
=ie??ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px"?:?

window.pageYOffset
+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top
=curY+offsetypoint+"px"
tipobj.style.visibility
="visible"
}
}
function?hideddrivetip(){
if?(ns6||ie){
enabletip
=false
tipobj.style.visibility
="hidden"
tipobj.style.left
="-1000px"
tipobj.style.backgroundColor
=''
tipobj.style.width
=''
}
}
document.onmousemove
=positiontip
</script>

?

實現(xiàn)效果:

?? 鼠標(biāo)移入67396...,會顯示全部內(nèi)容。

?

?

總結(jié)

以上是生活随笔為你收集整理的显示内容长时,显示部分内容,鼠标移入显示全部内容的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。