Reputation: 21986
I have download jquery-1.9.1 library, then I created a folder in NetBeans, called it "js" and used the src attribute:
<script type="text/javascript" src="js/jquery-1.9.1.js">
The problem is that if I include jquery some content of the page doesn't get included, which makes me think that the library is not properly included.
This is the full javascript code:
<script type="text/javascript" src="js/jquery-1.9.1.js">
function write()
{
var loc= document.getElementById("purchase");
var sep= location.href.indexOf("item=");
var item=parseInt(location.href.substring(sep+5,location.href.length));
switch(item)
{
case 1:
string= "Opere orchestrali vol. 1";
break;
case 2:
string= "Concerti per pianoforte n.1,n.4";
break;
case 3:
string= "Concerto di Capodanno 2013";
break;
case 4:
string= "Viva Verdi. Ouvertures & Preludes";
break;
case 5:
string= "Jaywalkin";
break;
case 6:
string= "The Real Life ";
break;
case 7:
string= "Shango";
break;
case 8:
string= "Complete Soul";
break;
case 9:
string= "Old Yellow Moon";
break;
case 10:
string= "In Time";
break;
case 11:
string= "Greatest Country Love Songs";
break;
case 12:
string= "Spring Break... here to Party";
break;
}
if(string !== undefined)
{
loc.innerHTML= "Acquisto effettuato: " + string;
}
}
</script>
The behavior is very simple: it just reads a get parameter named "item", and according to it's value (from 1 to 12) it puts the title of a disc inside a html tag.
If I don't include jquery it works perfecly, if I include jquery it doesn't work, and it doesn't put anything inside the tag.
Upvotes: 1
Views: 928
Reputation: 18064
You have not closed the script tag
<script type="text/javascript" src="js/jquery-1.9.1.js">
Change it to this
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
Note you can't add the js code between the another js file is included. It should be
<script>
...
...
...
</script>
Upvotes: 1
Reputation: 4009
You need to close the <script>
tag for the linked jQuery library and then add the rest of the JavaScript in a seperate set of tags. For example.
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
--------------------------------------------------------^^^^^^^^^
<script>
//The rest of your code
</script>
Upvotes: 6