Jquery Selecting Multiple Classes, Loading External Files
Posted
by
WillingLearner
on Stack Overflow
See other posts from Stack Overflow
or by WillingLearner
Published on 2010-12-25T20:39:16Z
Indexed on
2010/12/25
20:54 UTC
Read the original article
Hit count: 158
I have 2 links, with the class dynamicLoad.
<ul class="navbar">
<li><a href="Page3-News.html" class="dynamicLoad news">NEWS</a></li>
<li><a href="Page2-Events.html" class="dynamicLoad">EVENTS</a></li>
</ul>
and then I have this already working code, which loads external pages into a div named #MainWrapper:
<script type="text/javascript">
$( document ).ready( function() {
$( 'a.dynamicLoad' ).click( function( e ) {
e.preventDefault(); // prevent the browser from following the link
e.stopPropagation(); // prevent the browser from following the link
$( '#MainWrapper' ).load( $( this ).attr( 'href' ) );
});
});
</script>
How do I edit this code and my links, so that i can target the 1st link with the classes of both dynamicLoad and news, and then, load another script and/or pages into the main wrapper, without breaking its already working functionality?
© Stack Overflow or respective owner