jQuery Style How to - Change div visibility








Question

We would like to know how to change div visibility.

Answer


<!DOCTYPE html>
<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head><!--   w  w  w.j  ava2  s  .c  o  m-->
<body>
  <a class="abstractShow" href="#">Show</a>
  <div class="abstract" style="display: none;">ABSTRACT</div>
  <script>
$("a.abstractShow").click(function( e ){
    e.preventDefault();
    $(this).text( $(this).text()=='Show'?'Hide':'Show' ).next(".abstract").toggle(400);
});
</script>
</body>
</html>

The code above is rendered as follows: