jquery - Show DIV X, if Div Y contains Z. Then, show Div A, if Div Y contains B -
i've got code i've been working on, hash progress step bar.
the html:
<div id="stage1"><img src="/img/progress-bar/1.png"></div> <div id="stage2"><img src="/img/progress-bar/2.png"></div> <div class="deal-stage">2</div>
now want display div #stage1 if div .deal-stage contains number 1. want display div #stage2 if div .deal-stage contains number 2.
all html looks ok, it's jquery that's troubling me:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type='text/javascript'>//<![cdata[ $(window).load(function(){ if($('.deal-stage').html() == 1){ $("#stage1").show(); if($('.deal-stage').html() == 2){ $("#stage2").show(); } });//]]> </script>
at moment both divs showing. want add 4 more steps i'm not sure how display 1 of divs @ time looking number in .deal-stage div.
any ideas appreciated.
thank you!
s
hide images before page loads :
<div id="stage1" style="display:none;"><img src="/img/progress-bar/1.png"></div> <div id="stage2" style="display:none;"><img src="/img/progress-bar/2.png"></div> <div class="deal-stage">2</div>
then change script make little more compliant :
$(document).ready(function(){ if($('.deal-stage').html() == "1"){ $("#stage1").show(); } if($('.deal-stage').html() == "2"){ $("#stage2").show(); } });
and you'll go.
Comments
Post a Comment