2
Guys, here’s the thing, I’m trying to make a move only it’s not coming out like I hope.
*HTML code *
<div id="apresentar">
<img src="img2/fechar.png" class="fechar-foto">
<div id="foto-grande" ><img src="" width="100%" height="100%"><p></p></div>
</div>
<header>
<div id="logo"><a href="index.html"><img src="img2/Logo.png" width="220" height="220" class="logo zoom" alt="Página Inicial"></a></div>
<div id="sociais">
<a href="https://www.facebook.com/BlitzHaus" target="_blank"><img src="img/facebook.png" class="fade" alt="Facebook"></a>
<a href="https://twitter.com/blitz_haus" target="_blank"><img src="img/twitter.png" class="fade" alt="Twitter"></a>
</div>
</header>
<!--<nav class="fade-in um">-->
<nav>
<ul id="menu-principal">
<span class="ativo-desl"></span>
<li><a href="index.html">HOME</a></li>
<li><a href="programacao.html">PROGRAMAÇÃO</a></li>
<li><a href="parceiros.html">PARCEIROS</a></li>
<li><a href="galeria.html" class="ativo" id="selecionado">GALERIA</a></li>
<li><a href="localizacao.html">LOCALIZAÇÃO</a></li>
<li><a href="contato.html">CONTATO</a></li>
</ul>
</nav>
<div class="clear"></div>
<div id="corpo">
<section id="breadcrumb" class="fade-in um"><a href="index.html"><span>Home</span></a><span> > </span><span class="ativo">Galeria de Fotos</span></section>
<div id="conteudo">
<h1 id="titulo-principal" class="fade-in dois">GALERIA DE FOTOS</h1>
<img src="img2/galeria/img01.jpg" class="img-galeria fade-in tres" alt="Foto1">
<img src="img2/galeria/img02.jpg" class="img-galeria fade-in tres" alt="Foto2">
<img src="img2/galeria/img03.jpg" class="img-galeria fade-in tres" alt="Foto3">
<img src="img2/galeria/img04.jpg" class="img-galeria fade-in quatro" alt="Foto4">
<img src="img2/galeria/img05.jpg" class="img-galeria fade-in quatro" alt="Foto5">
<img src="img2/galeria/img06.jpg" class="img-galeria fade-in quatro" alt="Foto6">
<img src="img2/galeria/img07.jpg" class="img-galeria fade-in cinco" alt="Foto7">
<img src="img2/galeria/img08.jpg" class="img-galeria fade-in cinco" alt="Foto8">
<img src="img2/galeria/img09.jpg" class="img-galeria fade-in cinco" alt="Foto9">
<img src="img2/galeria/img10.jpg" class="img-galeria fade-in cinco" alt="Foto10">
<img src="img2/galeria/img11.jpg" class="img-galeria fade-in cinco" alt="Foto11">
<img src="img2/galeria/img12.jpg" class="img-galeria fade-in cinco" alt="Foto12">
<img src="img2/galeria/img13.jpg" class="img-galeria fade-in cinco" alt="Foto13">
</div>
</div>
Javascript code
$(function(){
$("#conteudo img").click(function(){
var image = $(this).attr('src');
var legenda = $(this).attr('alt');
$("#apresentar").fadeIn(300);
$("#foto-grande").fadeIn(300);
var vlr = $(this).position().top / 2;
$('#apresentar').css('top',vlr)
$('html, body').animate({ scrollTop: vlr}, 400);
$('#foto-grande img').attr('src', image);
$('#foto-grande p').text(legenda);
$('#foto-grande').hover(function(){ $('#foto-grande p').fadeIn(300)} , function (){$('#foto-grande p').fadeOut(300)});
document.body.style.overflow='hidden';
$('#apresentar').click(function(){ $('#apresentar').fadeOut(300); document.body.style.overflow='';});
});
});
function fechar(){
$('#apresentar').fadeOut(300);
document.body.style.overflow='';
}
I’m trying to do the following, when the person clicks on the present div he closes the div, and when the person clicks on the photo-large div does nothing, like facebook. But when I click on the photo-large div, it closes by being inside the present div.
Please help me out :'( .
Can you put all the HTML? missing elements like
#conteudo
– Sergio
"when the person clicks on photo-large div does nothing, like facebook. But when I click on the photo-large div, it closes by being inside the present div." I don’t understand.
– Luis Henrique
If I understand correctly, just use the method
stopPropagation
by clicking on the div#foto-grande
to prevent the event from being triggered on the parent elements. https://api.jquery.com/event.stoppropagation/– Oeslei
Oslei, that’s about it, how do I apply stopPropagation? Sergio the whole code is already available.,
– Romario Pires
Romario: what @Oeslei suggested is what you need (maybe he’ll get an answer out of it). Also take a look here to understand better what element you should refer to inside the Event Handler: http://answall.com/a/63399/129
– Sergio
Personal vlw for the help, thank you very much. : D
– Romario Pires
Romario, you can also use as: http://jsfiddle.net/q7hnbye0/, this code does what you want?
– Sergio
@Sergio, This class would be the X button this is already configured. My idea is like the facebook photos, when you click on one it opens locked the scroll bar and with a div that leaves the dark background, when you click on that dark part the photo closes and tbm on that X, the problem was that when I clicked on the photo, closed the photo too, but nothing was supposed to happen when I clicked on the photo. Got it?
– Romario Pires