借用別人的代碼實現(xiàn)一個效果
<!doctype?html> <html> <head> <meta?charset="utf-8"> <title>無標題文檔</title> <style?type="text/css"> *{ ???????margin:?0; ???????padding:?0; ???} ???#par_div{ ???????margin-left:?200px; ???????margin-top:?200px; ???????float:?left; ???????height:?200px; ???????width:?320px; ???} ???.list{ ???????height:?42px; ???????width:?320px; ???margin-left:?1px; ???} .list?li{ ???list-style-type:?none; ???width:?60px; ???height:?40px; ???line-height:?40px; ???text-align:?center; ???display:?inline-block; ???float:?left; ???border-left:?1px?solid?#336699; ???border-right:?1px?solid?#336699; ???border-top:?1px?solid?#336699; ???margin-left:?-1px; } .list?li?a{ ???text-decoration:?none; ???color:?darkgray; ???display:?block; } div#news1?{ ????margin-top:?-2px; ????z-index:?-1; } .news{ ???clear:?both; ???line-height:?25px; ???height:?158px; ???width:?320px; ???border:1px?solid?#336699; ???padding:?5px; } #new3,#news2{ ???display:?none; } </style> </head> <body> <div?id="par_div"> ???<ul?class="list"> ???????<li><a?href="#">房產(chǎn)</a></li> ???????<li><a?href="#">家居</a></li> ???????<li><a?href="#">二手房</a></li> ???</ul> ???<div?class="news"?id="news1"> ???????<p>275萬購昌平鄰鐵三居?總價20萬買一居</p> ???????<p>200萬內(nèi)購五環(huán)三居?140萬安家東三環(huán)</p> ???????<p>北京首現(xiàn)零首付樓盤?53萬購東5環(huán)50平</p> ???????<p>京樓盤直降5000?中信府?公園樓王現(xiàn)房</p> ???</div> ???<div?class="news"?id="news2"> ???????<p>40平出租屋大改造?美少女的混搭小窩</p> ???????<p>經(jīng)典清新簡歐愛家?90平老房煥發(fā)新生</p> ???????<p>新中式的酷色溫情?66平撞色活潑家居</p> ???????<p>瓷磚就像選好老婆?衛(wèi)生間煙道的設(shè)計</p> ???</div> ???<div?class="news"?id="new3"> ???????<p>275萬購昌平鄰鐵三居?總價20萬買一居</p> ???????<p>200萬內(nèi)購五環(huán)三居?140萬安家東三環(huán)</p> ???????<p>北京首現(xiàn)零首付樓盤?53萬購東5環(huán)50平</p> ???????<p>京樓盤直降5000?中信府?公園樓王現(xiàn)房</p> </div> </div> </body> </html>
怎么添加上js,讓效果變成點擊房產(chǎn)的時候顯示房產(chǎn)的內(nèi)容,點擊家居的時候顯示家居的內(nèi)容呢
2017-12-14
2017-12-15
。。。。
2017-12-14
哇 樓主 本來很簡單的問題 你的news1和2都是news? 怎么到了3就成了new3。。。整得我找了半天錯誤。截圖已奉上? 請放心食用。