I’m having trouble getting jQuery to load inside a file that has been imported using jQuery load.
Here is the code I’m using to get the external page:
<script type="text/javascript">
$(document).ready(function() {
$("#changeLinks a").click(function() {
$("#changeMe").fadeIn("slow").load($(this).attr('href'));
return false;
});
});
</script>
Aimed at a simple div (#changeMe).
I’ve heard about possibly using “live” but I don’t have any experience with that function so I’m confused.
Any help would be great.
Use Delegate instead. It’s faster than just a normal
livecall as it has a context. This means that events won’t need to bubble up to the top document level. You can accomplish the same withliveas of jQuery 1.4, but I preferdelegate‘s syntax.That having been said, I find your provided sample a bit weird. Is your click handler loading in dynamic data that should also fire that same click handler?