change css property when specific is in place - Javascript jQuery

Javascript examples for jQuery:CSS

Description

change css property when specific is in place

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
 </head> //from  w w w  . j  av  a 2s  .com
 <body> 
  <div class="div"></div> 
  <input type="button" value="toggle" class="toggle"> 
  <script type="text/javascript">
$(".toggle").click(function() {
    $(".div").css("height", function(i, val) {
        return val == '200px' ? '100%' : '200px';
    });
});

      </script>  
 </body>
</html>

Related Tutorials