Monday, August 29, 2016

Show and hide div on one button Click using jquery

In this article I am going to explain how to show and hide div on one button Click using jquery

Show and hide div on one button Click using jquery




Implementation:
You can show and hide div on button click using jquery Toggle function. I have created an example.

HTML markup:
<html>
<head>
  <title>toggle demo</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>
<body> 
<input type="submit" value="Show and Hide" id="button">
<div id="test">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>

<script>
    $("#button").click(function () {
        $("#test").toggle();
    });
</script>
</body>
</html>


No comments:

Post a Comment