Jump to content
php.lv forumi
  • 0

Jquert Hide visus div un Shov vienu


reiniger

Question

Sveiki.

 

Ielādēju lapā visus attēlus un ta lai no mazam bildītēm var pārslēgt lielās bildītes.

function pictureChangeID(id, value){
   $('div#small_gal').hide("fast", function () {
       $('#gal_smal'+id).show(); 
   });

html

<ul>
<li><a onclick="pictureChangeID(1);"><img src="/thumb1.jpg" alt="" height="52" width="79" /></a></li> 
<li><a onclick="pictureChangeID(2);"><img src="/thumb2.jpg" alt="" height="52" width="79" /></a></li> 
<li><a onclick="pictureChangeID(3);"><img src="/thumb3.jpg" alt="" height="52" width="79" /></a></li> 
</ul> 

<div id="small_gal"> 
<div id="gal_smal1" style="display: none;" >
 <a href="bilde1" class="pirobox" title=""><img src="bilde1.jpg" alt="" /></a>
</div>           
<div id="gal_smal2" style="display: none;" >
 <a href="bilde2" class="pirobox" title=""><img src="bilde2.jpg" alt="" /></a>
</div>           
<div id="gal_smal3" style="display: none;" >
 <a href="bilde3" class="pirobox" title=""><img src="bilde3.jpg" alt="" /></a>
</div>           
</div>

Patreic vienalga viss tiek paslēpts.

 

Ja lietoju tikai show tad parad bildi un parejas ar nak klat ja uzklikšķina uz thum bildi.

 

Ka panakt lai parejas tiek pasleptas un parads tikai konkrētā bilde?

Edited by reiniger
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

http://jsfiddle.net/LdvDx/1/

Eventus vajag definēt ar js.

 

html:

<ul class="thumbs">
<li><img src="http://www.freewebs.com/adr3naline/dodge-challenger-1970a.jpg" thumbfor="b1" /></li>
<li><img src="http://www.ecosherpa.com/images/dynasty_car.jpg" thumbfor="b2" /></li>
<li><img src="http://static.howstuffworks.com/gif/race-cars-2025-1.jpg" thumbfor="b3" /></li>
</ul>
<div id="large">
   <img id="b1" src="http://www.freewebs.com/adr3naline/dodge-challenger-1970a.jpg" alt="" />
   <img id="b2" src="http://www.ecosherpa.com/images/dynasty_car.jpg" alt="" />
   <img id="b3" src="http://static.howstuffworks.com/gif/race-cars-2025-1.jpg" alt="" />
</div>

 

css:

.thumbs li{
   display:inline-block;
}
.thumbs li img{
   width:64px;
   height:64px;
   border:1px solid #888;
   display:inline-block;
   cursor:pointer;
}
#large img{
   display:none;   
}
#b1{border:1px solid #f00}
#b2{border:1px solid #0f0}
#b3{border:1px solid #00f}

 

js:

$(function(){
   $('.thumbs img').bind('click',function(){
       iid=$(this).attr('thumbfor');
       $('#large img').hide();
       $('#'+iid).show();
   });
});

Edited by codez
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...