I want to crate a single-page website (top navigation, left sidebar, and a #content
div for exchanging content).
$(document).ready(function() { // or click on a button
$('#content').load('somepage.php');
});
<script src="jquery-1.9.1.min.js"></script>
<script src='index.js'></script>
scripts are outside loaded page, i.e. inside main page.
Two questions:
- Is there any issue or downside of this approach ?
- Why
jquery
works inside loaded#somepage.php
BUTindex.js
doesn't work ? I must write its code inside loaded page.
For example:
$("#stick").click(function() {
$(this).hide();
});
this code is inside index.js
.
stick
is inside somepage.php
. The code doesn' work till I write them inside somepage.php