So I've got a DIV (a map) that goes across the width of the page, but i'd like to have a button user开发者_如何学Pythons can click to "Hide/Unhide" the DIV that will basically do three things when clicked:
- scale the vertical height of the div to 25% of the original height...
- Change the DIV to have opacity .3 so its faded when at its reduced height...
- Revert back to normal height & opacity (1) when clicked again
Here's what I've got so far: Currently it only scales down to the correct vertical height
Really appreciate the help...
<!-- JQUERY STUFF ADDED IN THE HEAD-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<!-- THE CODE -->
<div id="map">
    Map Content Is Here
</div>
<p class="hidemap">HIDE MAP</p>
<script>
  $(document).ready(function() {
  $("p.hidemap").click(function () {
    $("#map").effect("scale", { percent: 25, direction: 'vertical' }, 500);
    });
   });
</script>
Try something like this:
var orig_height = $('#map').height();
$('.hidemap').click(function()
{
    if($('#map').height() == orig_height)
    {
        var new_height = Math.floor(orig_height * .25) + 'px';
        var new_opacity = '.3';
    }
    else
    {
        var new_height = orig_height + 'px';
        var new_opacity = '1';
    }
    $('#map').animate(
    {
        height: new_height,
        opacity: new_opacity
    },1000);
});
Working example: http://jsfiddle.net/X4NaV/
Based on Alien's, here you have:
<div id="map" style="overflow:hidden"> <!-- Look at the style -->
    Map Content Is Here <br>
    This is the seccond line
</div>
<p class="hidemap">HIDE MAP</p>
The script:
var orig_height = $('#map').height();
$('p.hidemap').click(function()
{
    var new_height = orig_height;
    var new_opacity = 1;
    if($('#map').height() == orig_height){
        new_height = Math.floor(orig_height * .01);
        new_opacity = .3;
    }
    $('#map').animate({
        height: new_height,
        opacity: new_opacity
    }, 2000);
});
Hope this helps. Cheers
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论