Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy am I getting a ReferenceError: not defined
    primarykey
    data
    text
    <p>i am trying to add jQuery to my page, I am getting this error though: ReferenceError: preview is not defined</p> <p>I have a js file in the js directory of my theme:</p> <pre><code>jQuery(document).ready(function() { function preview() { var hoverhome = 'url("images/Screen2.png") no-repeat'; var empty = ''; //home $('nav .home a').hover(function() { $('.viewport').css('background-image', hoverhome); }); $('nav .home a').onmouseout(function() { $('.viewport').css('background-image', empty); }); } }); </code></pre> <p>I have this in my functions file:</p> <pre><code>function add_my_script() { wp_enqueue_script( 'preview', get_template_directory_uri() . '/js/scriptfile.js', array('jquery') ); } </code></pre> <p>This is in my html head tag:</p> <pre><code>&lt;head&gt; &lt;meta charset="&lt;?php bloginfo( 'charset' ); ?&gt;" /&gt; &lt;title&gt;&lt;?php wp_title('|','true','right'); ?&gt;&lt;?php bloginfo('name'); ?&gt;&lt;/title&gt; &lt;meta name="viewport" content="width=device-width" /&gt; &lt;link rel="stylesheet" type="text/css" media="all" href="&lt;?php bloginfo( 'stylesheet_url' ); ?&gt;" /&gt; &lt;script type='text/javascript' src='&lt;?php bloginfo('template_url'); ?&gt;/scriptfile.js? ver=1.7.1'&gt;&lt;/script&gt; &lt;?php wp_head(); ?&gt; &lt;/head&gt; </code></pre> <p>and this is in my header to call the function:</p> <pre><code>&lt;div class="viewport"&gt; &lt;script type="text/javascript"&gt;&lt;!--//--&gt;&lt;![CDATA[//&gt;&lt;!-- preview(); //--&gt;&lt;!]]&gt;&lt;/script&gt; &lt;/div&gt; </code></pre> <p>finally, this is my css:</p> <pre><code>.viewport { height: 400px; width: 400px; position: relative; top: -90px; margin: 0 auto; } </code></pre> <p>But. I'm getting this error in firebug: </p> <pre><code>ReferenceError: preview is not defined </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload