I would like to know how to use my script within content that will be loaded by the load()
function.
The function:
$(document).ready(function() {
$('.submenu').click(function(event) {
event.preventDefault();
$('.page-wrapper').load($(this).data('href'));
});
});
The elements (outline):
<section class="page-wrapper">
<h1> Hello, guys! </h1>
<p> Este é um exemplo do conteúdo da página </p>
<ol class="menu">
<li><a class="submenu" data-href="www.example.com" href="#">Submenu1</a></li>
<li><a class="submenu" data-href="www.example.com" href="#">Submenu2</a></li>
<li><a class="submenu" data-href="www.example.com" href="#">Submenu3</a></li>
</ol>
</section>
That is, the menu will always load via load()
. With that my script does not work on the elements that are embedded in my "home page". How do I correct this defect?