wingman wingman - 7 months ago 28
HTML Question

Combining jQuery and normal JS

Basically what I want to do is load some text from a .txt and stuff it inside a paragraph. I'm still in a phase of experimentation so what's happening is I have 2 buttons that load text into a paragraph. Both work from within the same javascript with a switch case.

case '6':
vidljivo.innerHTML = slova.innerHTML;
break;

case '7':
$("#paragra").load( "1.txt" );
break;


The first one (case 6) loads text from a hidden div on the page, but since that's clunky I want to put the data on an external document. That's what the other button should do (case 7) but when I click on it I get an error saying $ is not defined. Not sure what I'm doing wrong so any idea is appreciated.

You can see both the script and the page and all at https://student.fsb.hr/~pi201247/diy

Answer

You can't use functions provided by the jQuery library without using a <script> element to load the jQuery library (available from http://jquery.com )