Skip to content

Instantly share code, notes, and snippets.

@m3g4p0p
Last active December 23, 2019 23:54
Show Gist options
  • Save m3g4p0p/71df72f5ba42c68e6f1bde81b9e0084e to your computer and use it in GitHub Desktop.
Save m3g4p0p/71df72f5ba42c68e6f1bde81b9e0084e to your computer and use it in GitHub Desktop.
Dynamic content test page
<h1>bar</h1>
<h1>foo</h1>
<a href="./bar.html">bar</a>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dynamic content test page</title>
<style>
.container {
padding: 10px;
margin: 10px;
border: 1px solid blue;
}
</style>
</head>
<body>
<div class="container">
<a href="./foo.html">foo</a>
</div>
<div class="container">
<a href="./bar.html">bar</a>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document.body).on('click', '.container a', function (event) {
event.preventDefault()
$(this).closest('.container').load(event.target.href)
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment