下面是html實(shí)現(xiàn)鼠標(biāo)懸停時(shí)顯示提示信息:

創(chuàng)新互聯(lián)主要從事網(wǎng)站設(shè)計(jì)制作、網(wǎng)站制作、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)蒲縣,10多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):13518219792
input?type="text"?title="日期格式為:yyyy/MM或yyyy/MM/dd"?/
jquery實(shí)現(xiàn):
$(input).addAttr('title','日期格式為:yyyy/MM或yyyy/MM/dd');
input?type="text"?/
先說(shuō)不用js的方法
給div添加一個(gè)title屬性即可(但是這樣是沒(méi)法操作到提示框的樣式的 所以有js方法)
js方法 下面給出一份演示
!DOCTYPE?HTML
html
head
title演示/title
script?src=""/script
style?type="text/css"
.TitleDiv{
width:300px;
background-color:?#dddddd;
color:?white;
padding:?15px?0;
}
.TitleDivText{
background-color:?rgba(0,0,0,0.5);
color:?white;
}
/style
/head
body
div?class="TitleDiv"
我是一個(gè)需要提示的div
/div
div?class="TitleDiv"
我是一個(gè)需要提示的div
/div
div?class="TitleDiv"
我是一個(gè)需要提示的div
/div
script?type="text/javascript"
//四個(gè)參數(shù)?
//Element表示需要提示的節(jié)點(diǎn)或者jq對(duì)象?可以是多個(gè)
//Text提示的文本
//Time?鼠標(biāo)移入等待多少的時(shí)間才顯示?單位毫秒
//Class?提示框的class屬性可以修改樣式
function?MoveTitle(Element,Text,Time,Class){
var?ElementJQ=$(Element);
//創(chuàng)建提示框
var?CreateTitle=function(event){
if(ElementJQ.TitleTime){
clearTimeout(ElementJQ.TitleTime);
ElementJQ.TitleTime=setTimeout(function(){
ElementJQ.TitleDiv=document.createElement("div");
if(Class){
$(ElementJQ.TitleDiv).addClass(Class);
}
$(ElementJQ.TitleDiv).css({
position:"fixed",
left:event.clientX+16+"px",//16是鼠標(biāo)的寬度
top:event.clientY+16+"px",//16是鼠標(biāo)的高度
});
$(ElementJQ.TitleDiv).html(Text);
document.body.appendChild(ElementJQ.TitleDiv);
},Time)
}else{
ElementJQ.TitleTime=setTimeout(function(){
ElementJQ.TitleDiv=document.createElement("div");
if(Class){
$(ElementJQ.TitleDiv).addClass(Class);
}
$(ElementJQ.TitleDiv).css({
position:"fixed",
left:event.clientX+16+"px",//16是鼠標(biāo)的寬度
top:event.clientY+16+"px",//16是鼠標(biāo)的寬度
});
$(ElementJQ.TitleDiv).html(Text);
document.body.appendChild(ElementJQ.TitleDiv);
},Time)
}
}
ElementJQ.on("mousemove",function(e){
clearTimeout(ElementJQ.TitleTime);
ElementJQ.TitleTime=null;
if(ElementJQ.TitleDiv){
document.body.removeChild(ElementJQ.TitleDiv);
ElementJQ.TitleDiv=null;
}
CreateTitle(e);
});
ElementJQ.on("mouseover",function(e){
CreateTitle(e);
});
ElementJQ.on("mouseout",function(){
clearTimeout(ElementJQ.TitleTime);
ElementJQ.TitleTime=null;
if(ElementJQ.TitleDiv){
document.body.removeChild(ElementJQ.TitleDiv);
ElementJQ.TitleDiv=null;
}
});
}
var?div=$(".TitleDiv")
MoveTitle(div,"我是提示的內(nèi)容",3000,"TitleDivText");
/script
/body
/html
先定義一個(gè)DIV,把你要提示的內(nèi)容,放到這個(gè)DIV中
div id="divInfo" style="visibility:hidden;"
p向上增加一行/pbr/
p修改此行/pbr/
p向下增加一行/p
/div
代碼:
$("table tr").mouseover(function(){
$("#divInfo").css("z-index",999);//讓層浮動(dòng)
$("#divInfo").css("top",this.top+行高);//設(shè)置提示div的位置
$("#divInfo").css("left",11);
$("#divInfo").css("visibility","visible");
})
就行了
這位網(wǎng)友你好,這個(gè)白色的窗口其實(shí)在鼠標(biāo)移上去之前是隱藏的,加了display:none屬性,當(dāng)鼠標(biāo)放上去后再顯示而已,display:block;,很簡(jiǎn)單的。
如果你用JQUERY UI的話會(huì)很簡(jiǎn)單的
先把 “script src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"/script” 加上
然后在“歡迎提意見(jiàn)”那個(gè)a里加上一個(gè)屬性“title”,也就是 a id="tiyijian" href="#" title="文字提示內(nèi)容"歡迎提意見(jiàn)/a
最后在mouseover的function里加上
$(this).tooltip({
position:?{
my:?"left?top",????????
at:?"right+5?top-5"
}
});
position 可自行做調(diào)整,css也可以添加,詳細(xì)看jquery-ui tooltip
標(biāo)題名稱:jquery鼠標(biāo)提示,jquery設(shè)置鼠標(biāo)樣式
網(wǎng)頁(yè)URL:http://chinadenli.net/article48/dsehpep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開(kāi)發(fā)、關(guān)鍵詞優(yōu)化、手機(jī)網(wǎng)站建設(shè)、商城網(wǎng)站、、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
網(wǎng)頁(yè)設(shè)計(jì)公司知識(shí)