當前位置:編程學習大全網 - 網站源碼 - JavaScript怎麽完成這個網頁的寫法!最好能夠提供例子或者源代碼!謝謝大神了!

JavaScript怎麽完成這個網頁的寫法!最好能夠提供例子或者源代碼!謝謝大神了!

<button?class="bxh">不喜歡</button>

<script>

var?bxh=document.querySelector(".bxh");

bxh.style.position="relative";

bxh.style.left="0px";

bxh.style.top="0px";

bxh.onmousemove=function(e){

var?e=e||window.event;

if(e.offsetX<this.offsetWidth/2)this.style.left=parseInt(this.style.left)+8+"px";

if(e.offsetX>this.offsetWidth/2)this.style.left=parseInt(this.style.left)-8+"px";

if(e.offsetY<this.offsetHeight/2)this.style.top=parseInt(this.style.top)+8+"px";

if(e.offsetY>this.offsetHeight/2)this.style.top=parseInt(this.style.top)-8+"px";

}

</script>

  • 上一篇:順豐如何查詢追蹤信息?
  • 下一篇:淘寶客PID是什麽?
  • copyright 2024編程學習大全網