Its gonna be simple, I know!! but cant figure out why all my different Modal windows are being called at the same time, even though each nav link as a unique #id link attributed to it.
HTML - NAV
<div id="main" class="faded-in">
<h3>
<a class="js-modal" href="#about">ABOUT</a> •
<a class="js-modal" href="#music">MUSIC</a> •
<a class="js-modal" href="#live">LIVE</a> •
</h3>
</div><!-- end of #main -->
HTML - Modal window
<article id="about" class="modal faded-out">
<div class="modal-spiel">
<p>content</p>
</div>
</article>
<article id="live" class="modal faded-out">
<div class="modal-spiel">
<p>content 2</p>
</div><!-- end of .modal-spiel -->
</article><!-- end of .modal faded-out -->
css
(modal windows are used a full screen overlay, presenting different page content)
jQuery
}), $(document).ready(function() {
$(".tubular-mute").click(function() {
$("a.tubular-mute").toggleClass("tubular-muted")
})
})),$(".js-modal").click(function() {
$("header, #main, .modal").toggleClass("faded-in").toggleClass("faded-out")
}), $(".modal").click(function() {
$("header, #main, .modal").toggleClass("faded-in").toggleClass("faded-out")
});
By using this selector
You're telling jquery to execute
.toggleClass
method on all elements withclass="modal"
, and since there are more than one such elements, all of your modal windows are opened at the same time.Assuming
ABOUT
link withhref="#about"
opens#about
modal window,MUSIC
link withhref="#music"
opens#music
modal window, andLIVE
link withhref="#live"
opens#live
modal window, you can replace this part of codewith this
To close the modal on click, replace this
with this