php - Hiding and showing divs depending on variable value -
can please tell me why code below not showing div ticker? shows div main ..
thanks lot!
<script language="javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('.ticker').hide(); $('.main').show(); $('.other').hide(); }) </script> <?php $main = 'ticker'; if ($main=="ticker"){?> <script type="text/javascript"> //alert('flag'); //this alert shows ok $('.ticker').show(); $('.main').hide(); $('.other').hide(); </script> <?php } ?> <div class="main">main</div> <div class="ticker">ticker</div> <div class="other">other</div>
looks you're missing $(document).ready()
second script block.
Comments
Post a Comment