{"id":6861009,"date":"2015-12-17T14:57:13","date_gmt":"2015-12-17T14:57:13","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/javascript-enqueued-correct-yet-cant-get-it-to-work\/"},"modified":"2016-08-30T21:27:05","modified_gmt":"2016-08-30T21:27:05","slug":"javascript-enqueued-correct-yet-cant-get-it-to-work","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/javascript-enqueued-correct-yet-cant-get-it-to-work\/","title":{"rendered":"Javascript enqueued correct, yet cant get it to work."},"content":{"rendered":"<p>I am making a custom theme, i have enqueued my js file as seen here:<\/p>\n<pre><code>function stage_script_enqueue() {\n\t\t\twp_enqueue_style( &#039;customstyle&#039;, get_template_directory_uri() . &#039;\/css\/stage.css&#039;, array(), &#039;1.0.0&#039;, &#039;all&#039; );\n\t\t\twp_enqueue_style( &#039;customstyle2&#039;, get_template_directory_uri() . &#039;\/css\/stage2.css&#039;, array(), &#039;1.0.0&#039;, &#039;all&#039; );\n\t\t\twp_enqueue_script( &#039;customjs&#039;, get_template_directory_uri() . &#039;\/js\/stage.js&#039;, array(), &#039;1.0.0&#039;, true );\n\t\t}\n\n\t\tadd_action( &#039;wp_enqueue_scripts&#039;, &#039;stage_script_enqueue&#039; );<\/code><\/pre>\n<p>when i put the line alert(&#8216;alert&#8217;); inside of the js file, it works perfectly fine, yet when i put this in it:<\/p>\n<pre><code>$(window).load(function() {\n\t$(&#039;#slider&#039;).nivoSlider({\n\t\teffect:&#039;random&#039;,\n\t\tslices:12,\n\t\tanimSpeed:500,\n\t\tpauseTime:2000,\n\t\tstartSlide:0, \/\/Set starting Slide (0 index)\n\t\tdirectionNav:false,\n\t\tdirectionNavHide:false, \/\/Only show on hover\n\t\tcontrolNav:false, \/\/1,2,3...\n\t\tcontrolNavThumbs:false, \/\/Use thumbnails for Control Nav\n\t\tpauseOnHover:true, \/\/Stop animation while hovering\n\t\tmanualAdvance:false, \/\/Force manual transitions\n\t\tcaptionOpacity:0.7, \/\/Universal caption opacity\n\t\tbeforeChange: function(){},\n\t\tafterChange: function(){},\n\t\tslideshowEnd: function(){} \/\/Triggers after all slides have been shown\n\t});\n\n    $(&#039;.hamburger&#039;).click(function(){\n        alert(&#039;geklikt!&#039;);\n        $(&#039;#tooplate_menu&#039;).toggleClass(&#039;slidedown&#039;);\n    });\n});<\/code><\/pre>\n<p>It does nothing at all, when inspecting the source code of the homepage, i do see my js file in there, but my slider and hamburger menu both do nothing.<\/p>\n","protected":false},"template":"","class_list":["post-6861009","topic","type-topic","status-publish","hentry","topic-tag-javascript"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6861009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6861009\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=6861009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}