Jquery Document Ready Can't Running In My View

anyone knows

why my jquery not running in my view

code like this

<script type="text/javascript">

jQuery(document).ready(function () {




maybe the answer

Presume the question is for Yii2 (since this is a Yii2 forum). Check the following:

  1. Have you included the JQuery asset in your view?

  2. You may directly register a js to a view which directly defaults to View::POS_READY

   $view->registerJs("alert('test')", $position); 

   // $position defaults to VIEW::POS_READY, 

You’re probably calling that code before jquery gets initialized. Use your browser’s developer tools by pressing f12 and then checking the console log.

(open it up first and then refresh the page to get the data)