Cara buat toogle hide and show div


Assalamu'alaikum wr wb
Kali ini saya akan share bagaimana Cara buat toogle hide and show div.

<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style type="text/css">
.box {
  background: goldenrod;
  width: 300px;
  height: 300px;
  margin: 30px auto;
  transition: all 2s linear;
  display: block;
}

.hidden {
  display: none;
}

.visuallyhidden {
  opacity: 0;
}

button {
  display: block;
  margin: 0 auto;
}
</style>
</head>
<body>
  <div id="box" class="box"></div>
 
  <button>TOGGLE VISIBILITY</button>

<script type="text/javascript">
var box = $('#box');

$('button').on('click', function () {

  box.toggleClass('visuallyhidden');
  box.toggleClass('hidden');

});
</script>
</body>
</html>


Semoga bermanfaat.
http://pangeran-it.blogspot.co.id/
Cara buat toogle hide and show div Cara buat toogle hide and show div Reviewed by Syawaluddin Amin, S.Kom on Juli 04, 2017 Rating: 5

Tidak ada komentar:

Diberdayakan oleh Blogger.