Q. querySelectorAllでaddEventListenerが動かない

Uncaught TypeError: document.querySelectorAll(...).addEventListener is not a function

jqueryだとfindで検索した結果に対してイベントリスナーの設定ができたが、javascriptではエラーになる。

querySelectorならできるが、やりたいのはそれではない。

jqueryでできる理由は、jqueryのonメソッドでは、検索された結果の各要素にイベントリスナーを設定している。

が、javascriptのaddEventListenerは要素1つに対して行う。

そのため、今回やりたいことを実現するには

A. ループして各要素にイベントリスナーを設定すること


Fatal error: Uncaught Error: Call to undefined function set_post_views() in /home/jszk/desnote.com/public_html/wpjs/wp-content/themes/the-thor-child/single.php:658 Stack trace: #0 /home/jszk/desnote.com/public_html/wpjs/wp-includes/template-loader.php(78): include() #1 /home/jszk/desnote.com/public_html/wpjs/wp-blog-header.php(19): require_once('/home/jszk/desn...') #2 /home/jszk/desnote.com/public_html/index.php(17): require('/home/jszk/desn...') #3 {main} thrown in /home/jszk/desnote.com/public_html/wpjs/wp-content/themes/the-thor-child/single.php on line 658