Skip to content

Instantly share code, notes, and snippets.

@davidsheardown
Created July 30, 2020 15:46
Show Gist options
  • Save davidsheardown/989bcea21dcea1255714822158d20f95 to your computer and use it in GitHub Desktop.
Save davidsheardown/989bcea21dcea1255714822158d20f95 to your computer and use it in GitHub Desktop.
Simple example of a div toggle (visible/in-visible) for quick ref
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<script>
$(document).ready(function () {
$("#toggle").click(function () {
$(".target").toggle('slow', function () {
// Any completion code
});
});
});
</script>
<a href="#" id="toggle"> Toggle </a>
<h1>Header Text</h1>
<div class="target" style="display: none;">
<br/>
<h1>This is the toggled DIV</h1>
<a href="https://codingandconsulting.com" target="_blank">Click for something</a>
</div>
<h1>More Text</h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment