本文目錄一覽:
js代碼實現滑鼠移動到上面一個效果,滑鼠離開效果保持
eg: jquery實現方法
你要加的樣式為.active ul–li實現tab
$(“.li”).on(“mouseover”,function(){
$(“li”).removeClass(“active”);
$(this).addClass(“active”);
});
ok!!
滑鼠事件,js代碼實現div移動功能
首先引入jquery框架 例如 jquery-1.7.1.js
//$(“#div1”)表示要移動的div
$(“#div1″).animate({top:’+=200px’},”slow”);//向上移動200px;
$(“#div1″).animate({top:’-=200px’},”slow”);//向下移動200px;回到原來的位置
滑鼠上下拖動網頁的JS
寫好了,注意禁止文本選擇功能只兼容了IE 火狐下只禁止了滑鼠右鍵,因為mousedown事件有衝突,你可以通過CSS來實現,達到完美兼容,CSS禁止文本選擇網上有資料我就不寫了。
script type=”text/javascript”
document.onmousedown = function ()
{
document.onmousemove= function (ev)
{
var oEvent = ev ||event;
window.scrollTo(oEvent.clientX,oEvent.clientY);
}
document.onmouseup = function ()
{
document.onmouseup = null;
document.onmousemove=null;
}
}
document.oncontextmenu = function ()
{
return false;
}
window.onload = function ()
{
var oBody = document.getElementsByTagName(‘body’);
oBody[0].oncopy= function ()
{
return false;
}
if(document.all)
{
document.onselectstart= function ()
{
return false;
}
}
}
/script
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/301142.html