jquery only working once

amalleytonrhj

New Member
I've got a ul with hidden list elements in default state:\[code\]$(function () { $("li.closed > ul").hide();});\[/code\]On Click I show the hidden list elements with toggling.\[code\]$("ul > li.closed").click(function () { var li = $(this).closest('li'); li.find(' > ul').slideToggle('fast'); $(this).toggleClass("closed open");});\[/code\]Everything is just working fine. But when I visit another page and return to my previous, the toggle is not working anymore - when I click they toggle out and instantly toggle back in.I'm loading my links in a div with this:\[code\]$(".link").click(function (e) { // Prevent the default action of the event e.preventDefault(); var linkHref = http://stackoverflow.com/questions/15844848/this.id +'.html'; $("#content").load(linkHref); $("#nav a.active").toggleClass('inactive active'); $(this).addClass("active").removeClass('inactive');});\[/code\]and therefore my html pages only exists of the body part and I'm loading the global.js everytime again, could this be a problem (with like caching or something)? Like this:\[code\]<script src="http://stackoverflow.com/questions/15844848/js/global.js" type="text/javascript"></script><article> <ul> <li class="closed">Headline <ul> <li class="fl"><a href="http://stackoverflow.com/questions/15844848/#"><img src="http://stackoverflow.com/questions/15844848/x.png"></a></li> <li class="fl"><a href="http://stackoverflow.com/questions/15844848/#"><img src="http://stackoverflow.com/questions/15844848/x.png"></a></li> </ul> </li> </ul></article>\[/code\]
 
Back
Top