jQuery "Hello World" not working

software development

#1

I have some background in Javascript, brand new to jQuery. Pulled up a beginners guide & found the following code:

<div id="divTest1"></div>
<script type="text/javascript">
function DocumentReady()
{
        $("#divTest1").text("Hello, world!");   
}

$(document).ready(DocumentReady);
</script>

I put this on my server in a .html file and the page is blank, but when I click “view example” on the tutorial site it works fine.

Do I need to do something to “switch on” jQuery?


#2

You need to load the jQuery library before you use it, e.g.

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

#3

Fixed my issue, thanks Andrew!