我猜會(huì)繼續(xù)提問(wèn)

創(chuàng)新互聯(lián)公司是一家專業(yè)的成都網(wǎng)站建設(shè)公司,我們專注成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、成都外貿(mào)網(wǎng)站建設(shè)、網(wǎng)絡(luò)營(yíng)銷、企業(yè)網(wǎng)站建設(shè),賣友情鏈接,廣告投放平臺(tái)為企業(yè)客戶提供一站式建站解決方案,能帶給客戶新的互聯(lián)網(wǎng)理念。從網(wǎng)站結(jié)構(gòu)的規(guī)劃UI設(shè)計(jì)到用戶體驗(yàn)提高,創(chuàng)新互聯(lián)力求做到盡善盡美。
script?type="text/javascript"
var?t;
$('.same-name?span').animate({top:?"0px",?opacity:?"0"});
$('.same-name?i?img').hover(function(){
//ImgToggle($(this),true);
$(this).parent().parent().children("span").stop().animate({top:?"-16px",?opacity:?"1"})
},function(){
t=setTimeout("ImgToggle("+$(this).parent().parent().index()+")",400);
console.log($(this).parent().parent().index());
}
)
$('.same-name?span').hover(function(){clearTimeout(t)},function(){
$(this).stop().animate({top:?"0px",?opacity:?"0"});
})
function?ImgToggle(i){
$('.same-name').parent().children().eq(i).find('span').animate({top:?"0px",?opacity:?"0"});
}?
/script
mouseover事件于用戶把鼠標(biāo)從一個(gè)元素移動(dòng)到另外一個(gè)元素上時(shí)觸發(fā),mouseout事件于用戶把鼠標(biāo)移出一個(gè)元素時(shí)觸發(fā)。\x0d\x0a下面為你詳細(xì)介紹下jquery中的鼠標(biāo)事件:\x0d\x0a(1):click事件:click事件于用戶在元素敲擊鼠標(biāo)左鍵,并在相同元素上松開(kāi)左鍵時(shí)觸發(fā);\x0d\x0a$('p').click(function(){\x0d\x0aalert('click function is running\x0d\x0a!');\x0d\x0a});\x0d\x0a(2):dbclick事件:dbclick事件在用戶完成迅速連續(xù)的兩次點(diǎn)擊之后觸發(fā),雙擊的速度取決于操作系統(tǒng)的設(shè)置。一般雙擊事件在頁(yè)面中不經(jīng)常使用;\x0d\x0a$('p').dbclick(function(){\x0d\x0aalert('dbclick function is running\x0d\x0a!');\x0d\x0a});\x0d\x0a(3):mousedown事件:mousedown事件在用戶敲擊鼠標(biāo)鍵時(shí)觸發(fā),跟keydown事件不一樣,該事件僅在按下鼠標(biāo)時(shí)觸發(fā);\x0d\x0a$('p').mousedown(function(){\x0d\x0aalert('mousedown function is\x0d\x0arunning !');\x0d\x0a});\x0d\x0a(4):mouseup事件:mouseup事件在用戶松開(kāi)鼠標(biāo)時(shí)觸發(fā),如果在與按下鼠標(biāo)的元素相同元素上松開(kāi),那么click事件也會(huì)觸發(fā);\x0d\x0a$('p').mouseup(function(){\x0d\x0aalert('mouseup function is running\x0d\x0a!');\x0d\x0a}).click(function(){\x0d\x0aalert('click\x0d\x0afunction is running too !');\x0d\x0a});\x0d\x0a(5):mouseover事件:mouseover事件于用戶把鼠標(biāo)從一個(gè)元素移動(dòng)到另外一個(gè)元素上時(shí)觸發(fā),如果需要知道來(lái)自那個(gè)元素可以使用,relatedTagrget屬性;\x0d\x0a(6):mouseout事件:mouseout事件于用戶把鼠標(biāo)移出一個(gè)元素時(shí)觸發(fā),這包括從父元素移動(dòng)到子元素上,或者使用鍵盤(pán)跳到元素上。
思路:
獲取移動(dòng)2個(gè)元素
給第一個(gè)元素加上鼠標(biāo)移入移除事件,
當(dāng)鼠標(biāo)移入時(shí),顯示div
當(dāng)鼠標(biāo)移除時(shí),隱藏div
代碼:
head?lang="en"
meta?charset="UTF-8"
title/title
style
div?{width:?100px;?height:?100px;?background:?#ccc;}
#div2?{display:?none;}
/style
script?src="js/jquery-1.7.2.js"/script
/head
body
div?id="div1"/div
div?id="div2"/div
/body
script
function?over(){
if(!$("#div2").is(":visible")){
$("#div2").show();????//如果元素為隱藏,則將它顯現(xiàn)
}else{
$("#div2").hide();?????//如果元素為顯現(xiàn),則將其隱藏
}
}
$('#div1').hover(over,over)
/script
樓上幾位代碼太多了,也不是純正的JQUERY代碼script type="text/javascript"
$(document).ready(function(){
$("li").mousemove(function (){
$(this).css("backgroundColor","grey");
});
$("li").mouseout(function (){
$(this).css("backgroundColor","");});
});
/script
!DOCTYPE?html
html
head?
meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"
script?type="text/javascript"?src=""/script
/head?
body?
script?type="text/javascript"?
$(document).ready(function(){
$('#mo').mousemove(function(e){
n=$('#xxx').val()-50;
m=$('#yyy').val()-50;
$('#mo').css({top:m+'px',?left:n+'px'});
});
});
function?mouseMove(ev)
{
Ev=?ev?||?window.event;
var?mousePos?=?mouseCoords(ev);
document.getElementById("xxx").value?=?mousePos.x;
document.getElementById("yyy").value?=?mousePos.y;
}
function?mouseCoords(ev)
{
if(ev.pageX?||?ev.pageY){
return?{x:ev.pageX,?y:ev.pageY};
}
return{
x:ev.clientX?+?document.body.scrollLeft?-?document.body.clientLeft,
y:ev.clientY?+?document.body.scrollTop?-?document.body.clientTop
};
}
document.onmousemove?=?mouseMove;?
/script?
鼠標(biāo)X軸:
input?id='xxx'?type='text'
鼠標(biāo)Y軸:
input?id=yyy?type=text?
div?id='mo'?style='position:absolute;width:200px;height:200px;background:red'111/div
/body
/html
你只要明白事件觸發(fā)的順序就知道原因了:當(dāng)你鼠標(biāo)移到div上的時(shí)候,觸發(fā)mouseenter事件,點(diǎn)擊的時(shí)候觸發(fā)click事件,然后鼠標(biāo)移走觸發(fā)mouseleave事件。
例如:var
test=0;
$("#div1").delegate("a",
"mouseenter",
function()
{
test=1;
}).delegate("a",
"mouseleave",
function()
{
test=2;
});
$("#div1").delegate("a",
"click",
function()
{
test=3;
});
當(dāng)你鼠標(biāo)移動(dòng)到div上點(diǎn)擊之后鼠標(biāo)再移走,最后觸發(fā)的事件是mouseleave事件,此時(shí)test是2而不是三。你可以測(cè)試一下
本文名稱:jquery鼠標(biāo)移動(dòng),jquery鼠標(biāo)移動(dòng)多張圖片加文字解說(shuō)
鏈接分享:http://chinadenli.net/article25/dsiseci.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、建站公司、網(wǎng)站內(nèi)鏈、企業(yè)網(wǎng)站制作、虛擬主機(jī)、自適應(yīng)網(wǎng)站
聲明:本網(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)