Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery is not defined although jQuery is loaded into the page before the calling script
    primarykey
    data
    text
    <p>I have an html "details" element that serves as my page's table of contents. I'm trying to dynamically rewrite the document's html "title" tag based on the currently "active" element in the TOC (a class="active")</p> <p>However, although it works in the console, when I actually embed it into the footer of my page, I'm getting a console error:</p> <blockquote> <p>Uncaught ReferenceError: jQuery is not defined</p> </blockquote> <p>I'm including jQuery into the footer of my page just before this inline script. Other jquery elements on the page are working fine. What could be the problem with this script?</p> <pre><code>&lt;script&gt; jQuery(document).ready(function(){ var title = jQuery('.myEl').find('a.active').text(); jQuery('title').text(title); }); &lt;/script&gt; </code></pre> <p>The HTML for this page looks like this:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en-US"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;Customer Testimonials (Page 3)&lt;/title&gt; &lt;link rel="stylesheet" href="styles.css" media="screen" /&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" /&gt; &lt;!--[if lt IE 9]&gt;&lt;script src="//html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;&lt;![endif]--&gt; &lt;/head&gt; &lt;body&gt; &lt;details class="myEl" open="open"&gt;&lt;summary&gt;In this article&lt;/summary&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="mypage/"&gt;Introduction&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="mypage/2/" class="active"&gt;Title for the second page&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="mypage/3/"&gt;Title for the third page&lt;/a&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/details&gt; &lt;script type='text/javascript' src='scripts.jquery.js' async='async'&gt;&lt;/script&gt; &lt;script&gt; jQuery(document).ready(function(){ var title = jQuery('.myEl').find('a.active').text(); jQuery('title').text(title); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    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.
    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