AZV AZV - 1 year ago 63
jQuery Question

jQuery - how can I replace part of page?

I've been trying to replace part of page marked as "content" with content of different html file. Unfortunately, I don't know much about JS.

Here's the code of index.html file:

<!DOCTYPE html>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="./js/jquery.js"></script>
$("home").on("click", function(){

<div id="header">
<table class="tg">
<th><a href="#" id="home">ABOUT</a></th>
<th><a href="#" id="contact">CONTACT</a></th>

<div id="content"></div>


And here's the home.html file:

<p>Content I want to see</p>

I've found similiar threads on stackoverflow (JS script is basically copied from here) but it still doesn't work. Can anybody explain to me what am I missing?

Answer Source

You're missing hash in front of id selector, your code should look like this:

    $("#home").on("click", function(){
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download