第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

這里的timer是全局的變量嗎?怎么沒有聲明,怎么不會報錯

<!DOCTYPE html>

<html>

<head>

? ? <meta charset="UTF-8">

? ? <title>Title</title>

? ? <style type="text/css">

? ? ? ? * {

? ? ? ? ? ? margin: 0;

? ? ? ? ? ? padding: 0;

? ? ? ? ? ? font: 12px '微軟雅黑';

? ? ? ? }

? ? ? ? #smooth div {

? ? ? ? ? ? float: left;

? ? ? ? }

? ? ? ? #smooth {

? ? ? ? ? ? height: 200px;

? ? ? ? ? ? width: 350px;

? ? ? ? ? ? position: absolute;

? ? ? ? ? ? left: -300px;

? ? ? ? ? ? top: 100px;

? ? ? ? }

? ? ? ? #content {

? ? ? ? ? ? background: #d3eff9;

? ? ? ? ? ? height: 200px;

? ? ? ? ? ? width: 300px;

? ? ? ? }

? ? ? ? #button {

? ? ? ? ? ? height: 50px;

? ? ? ? ? ? width: 25px;

? ? ? ? ? ? background: #d3eff9;

? ? ? ? ? ? cursor: pointer;

? ? ? ? }

? ? ? ? #button span {

? ? ? ? ? ? display: block;

? ? ? ? ? ? width: 12px;

? ? ? ? ? ? margin: 8px auto;

? ? ? ? }

? ? ? ? #wrap {

? ? ? ? ? ? height: 600px;

? ? ? ? ? ? background: #3979d9;

? ? ? ? }

? ? </style>

</head>

<body>

<div id="wrap"></div>

<div id="smooth">

? ? <div id="content"></div>

? ? <div id="button"><span>分享</span></div>

</div>

<script type="text/javascript">

? ? window.onload = function () {

? ? ? ? var divL = document.getElementById('smooth'),

? ? ? ? ? ? ? ? timer = null;

? ? ? ? function smoothing(iTarget) {

? ? ? ? ? ? clearInterval(timer);

? ? ? ? ? ? var speed = 0;

// ? ? ? ? ? ?var l = divL.offsetLeft;

? ? ? ? ? ? timer = setInterval(function () {

? ? ? ? ? ? ? ? var l = divL.offsetLeft;

? ? ? ? ? ? ? ? speed = (iTarget - l)/12;

? ? ? ? ? ? ? ? speed = speed>0?Math.ceil(speed):Math.floor(speed);

? ? ? ? ? ? ? ? if (l == iTarget) {

? ? ? ? ? ? ? ? ? ? clearInterval(timer);

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? else {

? ? ? ? ? ? ? ? ? ? l = l + speed;

? ? ? ? ? ? ? ? ? ? divL.style.left = l + 'px';

? ? ? ? ? ? ? ? ? ? /*console.log(l);

? ? ? ? ? ? ? ? ? ? console.log(divL.offsetLeft);

? ? ? ? ? ? ? ? ? ? console.log('speed:'+speed);*/

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }, 30);

? ? ? ? }

? ? ? ? divL.onmouseover = function () {

? ? ? ? ? ? smoothing(0);

? ? ? ? }

? ? ? ? divL.onmouseout = function () {

? ? ? ? ? ? smoothing(-300);

? ? ? ? }

? ? }

</script>

</body>

</html> ? ?<!--問題:這里的timer變量哪來的啊,都沒有聲明?。???-->



正在回答

1 回答

?var divL = document.getElementById('smooth'),

? ? ?timer = null;

這里已經(jīng)聲明了 ?這里同事聲明了2個變量,一個divL 一個timer ? ? ? ? 想一次聲明多個變量可以用逗號連接 例如:?

var a = 0, b=1, c =3;

這里同時聲明了a b c 三個變量并賦值

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

這里的timer是全局的變量嗎?怎么沒有聲明,怎么不會報錯

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號