Okay this one is really tricky for me, I've got 2 files a.php(in which I include b.php) and b.php. In a.php file I echo a variable containing navigation with some divs. In b.php file I'm holding this navigation in variable $layoutNavigation. How do I add an event listener to divs inside this $layoutNavigation? I've tried these ways:
1)I've tried to do it in a regular way:
$(".navMenuOpener").on("click", openNavMenu);
function openNavMenu()
{
alert();
}
2)Attempt(td is container in which I echo out navigation from b.php file):
$("#container > table td").on("click", "nav > #navigation > #web_links > .navMenuOpener", openNavMenu);
function openNavMenu()
{
alert();
}
I don't want to rewrite on every .navMenuOpener element onclick attribute, since that's pretty messy, what should I try?
EDIT: I'm pretty sure that if I add event listeners in a.php file everything would work fine, but I want to keep my layout in b.php file and all scripts that are responsible for anything that has something to do with layout.