Show or Hide division , click on checkbox


index.php


     

<!DOCTYPE html>

<head>

<meta charset="UTF-8">

<title>Show or Hide division , click on checkbox</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>

<body> 

<div class="container">

    <div class="row">

                <h3>Show or Hide division , click on checkbox</h3>

                <div class="col-lg-12">

                	

                </div>

            </div>

  <div class="well">

      <input type="checkbox" name="showorhide" id="showorhide" value="" />

  </div>

   <div class="well" id="divBox">

      <div class="media">

  		<a class="pull-left" href="#">

    		<img class="media-object" src="http://placekitten.com/150/150">

  		</a>

  		<div class="media-body">

    		<h4 class="media-heading">Receta 2</h4>

          <p class="text-right">By Anailuj</p>

          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra varius quam sit amet vulputate. 

Quisque mauris augue, molestie tincidunt condimentum vitae, gravida a libero. Aenean sit amet felis 

dolor, in sagittis nisi. Sed ac orci quis tortor imperdiet venenatis. Duis elementum auctor accumsan. 

Aliquam in felis sit amet augue.</p>

          <ul class="list-inline list-unstyled">

  			<li><span><i class="glyphicon glyphicon-calendar"></i> 2 days, 8 hours </span></li>

            <li>|</li>

            <span><i class="glyphicon glyphicon-comment"></i> 2 comments</span>

            <li>|</li>

            <li>

               <span class="glyphicon glyphicon-star"></span>

                        <span class="glyphicon glyphicon-star"></span>

                        <span class="glyphicon glyphicon-star"></span>

                        <span class="glyphicon glyphicon-star"></span>

                        <span class="glyphicon glyphicon-star-empty"></span>

            </li>

            <li>|</li>

            <li>

            <!-- Use Font Awesome http://fortawesome.github.io/Font-Awesome/ -->

              <span><i class="fa fa-facebook-square"></i></span>

              <span><i class="fa fa-twitter-square"></i></span>

              <span><i class="fa fa-google-plus-square"></i></span>

            </li>

			</ul>

       </div>

    </div>

  </div>

</div>

</body>

</html>



    

custom.js


     

<script>

$(document).ready(function(e) {

  $(document).on('click','#showorhide',function(){

    if($("#showorhide").is(':checked')){

	    $("#divBox").hide();

	  }

	else{

	   $("#divBox").show();

	  }  

  }); 

});

</script>