為什么alert出來的值是0,這樣沒法繼續(xù)寫了
<!DOCTYPE html>
<html>
<head>
? ? <meta charset="UTF-8">
? ? <title>實踐題 - 選項卡</title>
? ? <style type="text/css">
? ? ? ?#ul li{float:left;border-right:1px solid gray;border-left:1px solid gray;margin-right:10px;padding:5px 10px;
? ? ? ?width:50px;text-align:center;vertical-align:middle;}
? ? ? ?#ul{overflow:auto;margin-left:2px;z-index:999;position:relative;margin-top:1px;}
? ? ? ?*{list-style:none;margin:0;padding:0;}
? ? ? ?.li_second,.li_third{border-top:1px solid gray;
? ? ? ? ? ? ? ? ? ? ? ? ? ? border-bottom:1px solid red;}
? ? ? ?.li_first{border-bottom:1px solid white;
? ? ? ? ? ? ? ? ?border-top:1px solid red;}
? ? ? ?
? ? ? ?.content{border-left:1px solid blue;
? ? ? ? ? ? ? ? border-right:1px solid blue;
? ? ? ? ? ? ? ? border-bottom:1px solid blue;
? ? ? ? ? ? ? ? border-top:1px solid red;width:280px;
? ? ? ? ? ? ? ? position:absolute;top:31px;
? ? ? ?}
? ? </style>
? ? <script type="text/javascript">
? ? ? ?
? ? ?
? ? ? ? ? var x=document.getElementsByTagName("li");
? ? ?alert(x.length);
? ? ??
? ??
? ? </script>
?
</head>
<body>
<div id="div">
<ul id="ul">
? ? <li class="li_first">房產(chǎn)</li>
? ? <li class="li_second">家居</li>
? ? <li class="li_third">二手房</li>
</ul>
</div>
<div class="content">275萬購昌平鄰鐵三居 總價20萬買一居</br>
? ? ?200萬內(nèi)購五環(huán)三居 140萬安家東三環(huán)</br>
? ? ?北京首現(xiàn)零首付樓盤 53萬購東5環(huán)50平</br>
? ? ?京樓盤直降5000 中信府 公園樓王現(xiàn)房
</div>
?
</body>
</html>
2018-03-01
你可以試試不要alert 。然后繼續(xù)寫。