HTML我visibility_toggle不工作,我希望它
<article class="col1 pad_left1">
<div class="box1">
<div class="box1_bot">
<div class="box1_top">
<div class="pad">
<h2>CLIENTS</h2>
<button style="background:url(images/box_top.jpg) center top no-repeat; width:100%; text-align:center; padding:5px; color:white;" onclick="toggle_visibility('demo1');" id="C4M">Consultants4Manpower</button>
<div id="demo1" style: "visibility:hidden;">
<marquee behavior="scroll" direction="down">
<img src="images/CII logo.png" height="80px" width="80px" alt="">
<img src="images/Rotary logo.gif" height="80px" width="80px" alt="">
<br/>
<img src="images/Tie logo.png" height="80px" width="80px" alt="">
</marquee>
</div>
<hr/>
<button style="background:url(images/box_top.jpg) center top no-repeat; width:100%; text-align:center; padding:5px;" onclick="toggle_visibility('demo2');" id="corporate">Corporate Training</button>
<div id="demo2" style: "visibility:hidden;">
<marquee behavior="scroll" direction="down">
<img src="images/CII logo.png" height="80px" width="80px" alt="">
<img src="images/Rotary logo.gif" height="80px" width="80px" alt="">
<br/>
<img src="images/Tie logo.png" height="80px" width="80px" alt="">
</marquee>
</div>
<hr/>
<button style="background:url(images/box_top.jpg) center top no-repeat; width:100%; text-align:center; padding:5px;" onclick="toggle_visibility('demo3');" id="EPD">English & PD Training</button>
<div id="demo3" style: "visibility:hidden;">
<marquee behavior="scroll" direction="down">
<img src="images/CII logo.png" height="80px" width="80px" alt="">
<img src="images/Rotary logo.gif" height="80px" width="80px" alt="">
<br/>
<img src="images/Tie logo.png" height="80px" width="80px" alt="">
</marquee>
</div>
<hr/>
<button style="background:url(images/box_top.jpg) center top no-repeat; width:100%; text-align:center; padding:5px; font-color:white;" onclick="toggle_visibility('demo4');" id="P4E">Paterns4Education</button>
<div id="demo4" style: "visibility:hidden;">
<marquee behavior="scroll" direction="down">
<img src="images/CII logo.png" height="80px" width="80px" alt="">
<img src="images/Rotary logo.gif" height="80px" width="80px" alt="">
<br/>
<img src="images/Tie logo.png" height="80px" width="80px" alt="">
</marquee>
</div>
</div>
</div>
</div>
</div>
</article>
JAVASCRIPT
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block') e.style.display = 'none';
else e.style.display = 'block';
}
我面臨的問題是,當我加載頁面的所有四個部分顯示圖像同時滾動。我想要的是當我去的頁面沒有圖像滾動是可見的。當我點擊1說consultants4manpower然後只有圖像下該div變成可見滾動down.and進一步當我點擊第二個時,前一個變爲不可見,第二個變爲可見。 看看這個鏈接: http://shubhamenterprises.education/about.html
因此整個問題是,你點擊不同的按鈕後,前面的div不會成爲無形? – nowhere
是的,當我們打開上述鏈接時,您可能已經注意到所有四個div都可見。我只希望它們在我點擊特定按鈕時可見 –
@RajatGoyal如果它對您有幫助,您是否願意接受我的答案? –