javascript - Hide and show using JQuery -


i have many divs ids in 1 class.how show 1 , hide rest? here goes html 3 such divs

<div class="build">    <div id="slide1">       <!--slide1 elements -->    </div>    <div id="slide2">       <!--slide2 elements-->    </div>    <div id="slide3">       <!--slide2 elements-->    </div> </div> 

this ive tried js:

if (exp_id == "a_exp1") {     new_exp_id = exp_id;      $("#right").html("<div><img id='myimage1' onclick='changeimage1()' src='images/build_i.png'/>") }  function changeimage1() {     (var n = 1; n <= 3; n++) {         if (new_exp_id == "a_exp" + n) {               $('.build').hide();             $('.build').find('#slide' + n).show();         }     } }    

so, if a_exp1, should correspond slide1, if a_exp2, should correspond slide2 , on.

i need show 1 div , hide rest. how do this? have hidden entire class in beginning of html.

$('.build').children('div').click(function() {     $(this).show().siblings().hide(); }); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -