[問題] 用css作選單
<div x1>主選項1</div>
<div y1>次選項1.1
次選項1.2</div>
<div x2>主選項2</div>
<div y2>次選項2.1
次選項2.2
次選項2.3</div>
像是這樣的選單 可以收合 (選單資料是從資料庫抓的)
.status1 {
display: none;
}
.status2 {
display: block;
}
目前是利用onclick 當點擊到主選項x1時 次選項y1的status變成2 其他為1
點擊到主選項x2時 主選項y2的status變成1 其他為2
(就是打開自己 關掉其他的 所以會有一個主選項是打開的)
請問有辦法讓他自己判斷
如果本身status 是1 的話 點擊就變成2
是2 的話 點擊就變成1
(讓他能全部關閉 或全部打開)
有辦法這樣子嗎!?
--
◢ █◣ ◢◢◣ ◢◣◥████
◢███◣ ◢ ◣ █╴█╴█ ████
███▉█ ◢█◢ ◣◢ ██ ≡███≡ ◥█
███▉█ ◢▉█ ◢██ ███ ◢██ ◢██ ███ ◥█﹋█◤ ◎ █
█▇▇▇◤ █▉█ █▇▇ █▇▏ ▉▇▇ █▉█ ██ ▉▉█▏▏/ ◢█
██▇▏◣ █▇█ ▇▇█ ██▏ ███ █▇█▎██ █▉▉█▏▏█ rushcat
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.119.199.250
※ 編輯: rushcat 來自: 140.119.199.250 (09/08 01:38)
推
09/08 01:58, , 1F
09/08 01:58, 1F
推
09/08 10:25, , 2F
09/08 10:25, 2F
討論串 (同標題文章)