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

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

getLeft和getTop函數哪里出問題了


getLeft和getTop函數哪里出問題了,瀏覽器報錯offsetLeft沒有定義

<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> -->

<head>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

<title>Document</title>

<style type="text/css">

? ? body{

? ? ?background: #333;

? ? }

? ? .bg_div{

? ? ?background-image: url("river.jpg");

? ? ?height: 690px;

? ? ?width: 1268px;

? ? ?margin: 0 auto;

? ? ?position: relative;


? ? }

? ? .logo{

? ? ?background-image: url("logo.png");

? ? ?height:53px;

? ? ?width:107px;

? ? ?float: left;

? ??

? ? ?margin: -5px 18px 0 0;

? ? }

? ? .search-form{

? ? ?float: left;

? ? ?background: #fff;

? ? ?padding: 5px;

? ? ? ?/* width: 388px;*/

? ? }

? ? .search-text{

? ? ?border: 0;

? ? ?float: left;

? ? ?height: 25px;line-height: 25px;

? ? ?outline: none;//

? ? ?width: 350px;

? ? }

? ? .search-submit{

? ? ?border: 0;

? ? ?background-image: url(search-button.png);

? ? ?height: 29px;

? ? ?width:29px;

? ? ?float: left;


? ? }

? ? .box{

? ? ?position: absolute;

? ? ?top: 200px;

? ? ?left: 400px;

? ? }

? ? .suggest{

? ? ? ? width: 388px;

? ? ? ? background: #fff;

? ? ? ? border: 1px solid #999;

? ? }

? ? .suggest ul{

? ? ? ? list-style: none;

? ? ? ? margin: 0;

? ? ? ? padding: 0;

? ? }

? ? .suggest ul li{

? ? ? ? padding: 5px;

? ? ? font-size: 12px;

? ? ? line-height: 25px;

? ? ? cursor: pointer;

? ? }

? ? .suggest ul li:hover{

? ? ? ? background: #ccc;

? ? ? ? text-decoration: underline;

? ? }

</style>

</head>

<body>

<div>

<div>

<div></div>

<form action="https://cn.bing.con/search" target="_blank" id="search-form" >

<input type="text" name="q" id="search-input" autocomplete="off">

<input type="submit" value="">

</form>

</div>

</div>

<div id="search-suggest" style="display:none">

<ul id="search-result">

<li>搜索結果1</li>

<li>搜索結果2</li>

</ul>

</div>

<script type="text/javascript">

function getDom(id){

return document.getElementById(id);

}

function addEvent(id,event,fn){

var ele = getDom(id)||document;

if(ele.addEventListener){

ele.addEventListener(event,fn,false);

}else if(ele.attachEvent){

ele.attachEvent('on'+event,fn);

}

}

? ? function getLeft(ele){

? ? ? ? var actualLeft = ele.offsetLeft;

? ? ? ? var current = ele.offsetParent;

? ? ? ? while(current!=null){

? ? ? ? ?actualLeft +=current.offsetLeft;

? ? ? ? ?current = current.offsetParent;

? ? ? ? }

? ? ? ? return actualLeft;

? ? }

? ? function getTop(ele){

? ? ? ?

? ? ? ? var actualLeft = ele.offsetTop;

? ? ? ? var current = ele.offsetParent;

? ? ? ? while(current!=null){

? ? ? ? ?actualTop +=current.offsetTop;

? ? ? ? ?current = current.offsetParent;

? ? ? ? }

? ? ? ? return actualTop;

? ? }

? ? addEvent('search-input','keyup',function(){

? ? ?getDom('search-suggest').style.left = getLeft(getDom('search-form'));

? ? ?getDom('search-suggest').style.top = getTop(getDom('search-form'))+38+'px';

? ? ?getDom('search-suggest').style.position = 'absolute';

? ? ?getDom('search-suggest').style.display = 'block';

? ? })

</script>

</body>

</html>


正在回答

3 回答

謝謝你啊,自己檢查不仔細

0 回復 有任何疑惑可以回復我~

http://img1.sycdn.imooc.com//58ec5c53000133f302830182.jpg這是你的getLeft(ele)函數

http://img1.sycdn.imooc.com//58ec5c7c00016b0a02450200.jpg注意這里你自己定義的變量名。然后再看看你的返回值。

0 回復 有任何疑惑可以回復我~

沒人回答嗎

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
搜索框制作
  • 參與學習       66019    人
  • 解答問題       463    個

本課程從簡入深講解搜索框的制作,學習JQ與JS實現(xiàn)Ajax技術的不同點

進入課程

getLeft和getTop函數哪里出問題了

我要回答 關注問題
微信客服

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

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號