javascript - Jquery: if link is clicked open pop up and close all current pop up which are open -
i managed create jquery command opens pop (.more-news
). in page there several links open different pop up's. pop has closing button, if user clicks on link opens pop overlay each other shown on image. avoid want jquery command if click link open pop first closes other open pop avoid overlay.
any suggestions?
post link open pop up:
<article class="news-thumb"> <time>08/07/2013</time> <div class="news-info"> <img src="images/news/post-2.jpg" alt="#"> <h1>main title</h1> <p>lorem ipsum su madre. lorem ipsum su madre. lorem ipsum... </p> <a href="#" class="more-btn-2">read more <i class="sprites-more-news"></i></a> </div> </article>
pop code:
<article class="more-block-1"> <div class="more-news"> <h1>main title</h1> <a href="#" class="pop-link"> <i class="sprites-pop-news-close"></i> </a> <div class="more-text"> <p> donec ligula eget dolor ornare adipiscing. ut varius pulvinar nisi eget feugiat. sed dictum ante nec pharetra tincidunt. nulla eget aliquam lacus, vitae ullamcorper lacus. suspendisse ultricies quis orci in aliquam. morbi eget elit felis. etiam consectetur eleifend libero varius lacinia. proin justo felis, viverra lobortis </p> <p> donec ligula eget dolor ornare adipiscing. ut varius pulvinar nisi eget feugiat. sed dictum ante nec pharetra tincidunt. nulla eget aliquam lacus, vitae ullamcorper lacus. suspendisse ultricies quis orci in aliquam. morbi eget elit felis. etiam consectetur eleifend libero varius lacinia. proin justo felis, viverra lobortis </p> </div> </div> </article>
jquery command fade in pop up:
all pop codes have in common class .more-news
.
$(function() { $(".more-btn-1").on('click', function() { // code closes rest of open pop ups $('.more-block-1').fadein('slow'); return false; }); });
if popups share class .more-news
, can hide element class before show current popup.
code:
$(function() { $(".more-btn-1").on('click', function() { // code closes rest of open pop ups $('.more-news').not('.more-block-1').fadeout(); $('.more-block-1').fadein('slow'); return false; }); });
example: http://codepen.io/skimberk1/pen/28f7917d229a359de7ee13557d742843
dryer example: http://codepen.io/skimberk1/pen/a0c35556dd938c87159ebac81d141290
Comments
Post a Comment