我在我的html文件中有以下代碼,我在其中顯示兩個可點擊的區域,但它只讓我點擊一個。我可以看到兩者,但我只能點擊最後定義的那個。div問題html,css
<div style="visibility:hidden; position:absolute; padding-left:360px; padding-top:80px; float:left" id="colors">
<h2 style = "cursor:pointer" onclick="changecolor()">button1</h2>
</div>
<div style="visibility:hidden; position:absolute; padding-left:360px; padding-top:410px; float:left" id="stylescroll">
<h2 style="cursor:pointer" onclick="changedesign()">button2 </h2>
</div>
function showt(){
removeall();
var hide = document.getElementById("center");
hide.style.backgroundImage = "url(tshirts.jpg)";
var shirt = document.getElementById("shirt");
shirt.style.visibility = "visible";
var move = document.getElementById("shirtmove");
move.style.visibility = "visible";
var logo = document.getElementById("advisory");
logo.style.visibility = "visible";
var button1 = document.getElementById("stylescroll");
button1.style.visibility = "visible";
var button = document.getElementById("colors");
button.style.visibility = "visible";
}
函數showt是使兩個對象都可見的函數。所以當這個函數被調用時,我可以看到button1和button2文本,但我無法與button1交互,button2工作正常。
任何想法?
你有jsFiddle的例子嗎? – 2011-05-12 21:54:24