1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

display = "block";

Posted at

divタグとかの表示、非表示を切り替える関数を作った。けど、。

change_menu.js
function change_menu(num) {
  var ul1 = document.getElementById('menu1');
  var ul2 = document.getElementById('menu2');

  ul1.style.display = "none";
  ul2.style.display = "none";

  if(num==1) ul1.style.display = "block";
  if(num==2) ul2.style.display = "block";
}

だと正常に表示されない。

  if(num==1) ul1.style.display = "block";
  if(num==2) ul2.style.display = "block";

この部分を

setTimeout(function(){
  if(num==1) ul1.style.display = "block";
  if(num==2) ul2.style.display = "block";
},0}

のように書き換えることで正常に動くようになった。
ちなみに実行環境はpanasonicテレビのアクトビラで用いられているwebブラウザ。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?