teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

文法の修正

2018/03/05 15:44

投稿

takna
takna

スコア784

answer CHANGED
@@ -44,9 +44,9 @@
44
44
  var menu = document.querySelectorAll( '.menu' );
45
45
 
46
46
  Array.prototype.forEach.call( menu, function( item ) {
47
- item.onclick = function() {
47
+ item.addEventListener( 'click', function() {
48
48
  this.querySelector( '.smenu' ).classList.toggle( 'active' );
49
- };
49
+ });
50
50
  });
51
51
  </script>
52
52
  </body>