Sanjay Cruze Sanjay Cruze - 3 months ago 9
HTML Question

Jquery/javascript not working

I'm new to creating websites, and am unsure as to why I can't get jquery/javascript to work. I'm trying to make a page which has dynamic tabs, copied from http://www.jankoatwarpspeed.com/dynamic-tabs-using-jquery-why-and-how-to-create-it/. My current file is as follows,

<div id="doclist">
<h2>Documents</h2>
<ul id="documents">
<li><a href="#" rel="Document1" title="Content of Document1">Document1</a></li>
<li><a href="#" rel="Document2" title="Content of Document2">Document2</a></li>
<li><a href="#" rel="Document3" title="Content of Document3">Document3</a></li>
<li><a href="#" rel="Document4" title="Content of Document4">Document4</a></li>
<li><a href="#" rel="Document5" title="Content of Document5">Document5</a></li>
</ul></div><div id="wrapper">
<ul id="tabs">
<!-- Tabs go here -->
</ul>
<div id="content">
<!-- Tab content goes here -->
</div>




<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js">
$( document ).ready(function() {
console.log( 'ready!' );
});
</script>


For some reason, I cannot see "ready!" in the browser console. I have checked a couple other pages and I feel I am missing something basic, but being so new to this I can't see it. Thanks in advance for your help.

Kld Kld
Answer

You need to use tow javascript tags one for to load the jQuery and an other one for your code.

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
$( document ).ready(function() {
    console.log( 'ready!' );
});
</script>
Comments