บทความนี้อธิบายวิธีการของ JS เพื่อรับรู้การเลื่อนภาพหยุดเมื่อเมาส์ผ่าน แบ่งปันสำหรับการอ้างอิงของคุณ วิธีการใช้งานเฉพาะมีดังนี้:
การคัดลอกรหัสมีดังนี้:
<! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html; charset = gb2312" />
<title> เมื่อเมาส์ผ่านไป <a href = 'sitejs-16691-1.html' target = '_ blank'> <u> การเลื่อนภาพ </u> </a> หยุดเอฟเฟกต์ </title>
</head>
<style type = "text/css">
-
#www_jb51_net {
ความเป็นมา: #FFF;
ล้น: ซ่อน;
เส้นขอบ: 1px ประ #CCC;
ความกว้าง: 325px;
ความสูง: 245px;
-
#www_jb51_net img {
ชายแดน: 3px Solid #F2F2F2;
-
#Indemo {
ลอย: ซ้าย;
ความกว้าง: 800%;
-
#demo1 {
ลอย: ซ้าย;
-
#demo2 {
ลอย: ซ้าย;
-
-
</style>
<body>
เลื่อนไปทางซ้าย
<div id = "www_jb51_net">
<div id = "indemo">
<div id = "demo1">
<a href = "#"> <img src = "images/m01.jpg"/> </a>
<a href = "#"> <img src = "images/m02.jpg"/> </a>
<a href = "#"> <img src = "รูปภาพ/m03.jpg"/> </a>
<a href = "#"> <img src = "images/m04.jpg"/> </a>
<a href = "#"> <img src = "รูปภาพ/m05.jpg"/> </a>
<a href = "#"> <img src = "images/m06.jpg"/> </a>
</div>
<div id = "demo2"> </div>
</div>
</div>
<script>
-
var speed = 10;
var tab = document.getElementById ("www_jb51_net");
var tab1 = document.getElementById ("demo1");
var tab2 = document.getElementById ("demo2");
tab2.innerhtml = tab1.innerhtml;
ฟังก์ชั่น Marquee () {
if (tab2.offsetWidth-tab.scrollleft <= 0)
tab.scrollleft- = tab1.offsetWidth
อื่น{
tab.scrollleft ++;
-
-
var mymar = setInterval (Marquee, ความเร็ว);
tab.onMouseOver = function () {clearInterval (mymar)};
tab.onmouseout = function () {mymar = setInterval (marquee, speed)};
-
</script>
</body>
</html>
ฉันหวังว่าบทความนี้จะเป็นประโยชน์กับการเขียนโปรแกรม JavaScript ของทุกคน