I know this has been asked multiple times but I can't figure out why this won't work for me. Trust me, I've done research but I still can't see what's wrong with this. I'm also a complete noob at html and javascript/jquery so please be nice :)
My goal is to load a simple text from text.html
onto index.html
using jQuery.
This is my code as of right now
index.html
<head>
<script src="jquery-3.4.1.min.js"></script>
<script>
$(document).ready(function(){
$('#content').load("text.html");
});
</script>
</head>
<body>
<div id="content"></div>
</body>
text.html
<body>
<p>Hello there!</p>
</body>
I have jQuery 3.4.1 in the same folder as these two files as well. When I drag index.html into Google Chrome I get a blank page. Of course, if I had any text in index.html
it did show up when I loaded the html.
I'd also like to mention that I'm using <div>
because I'm trying to do the same thing on another project by loading a div onto an html, so I'm seeing if even this small code would work, but sadly it's not. I've changed <div>
in index.html
into <p>
and it made no difference.
Any help would be greatly appreciated!
Edit: My goal is to have "hello there!" display. When I drag index.html
into my web browser to preview what my output should look like, "Hello there!" does not display - instead, I get a blank page. I've tested index.html
to have some other text in it, and it displays perfectly fine. The problem is that code from text.html
doesn't seem to display.