Skip to content

Instantly share code, notes, and snippets.

@considine
Created October 16, 2018 15:27
Show Gist options
  • Select an option

  • Save considine/a1b713eaf0b31cd4a1418fda09e6c1f4 to your computer and use it in GitHub Desktop.

Select an option

Save considine/a1b713eaf0b31cd4a1418fda09e6c1f4 to your computer and use it in GitHub Desktop.
<style>
.controls {
display: none;
}
@media (max-width: 800px) {
.plan {
display: none;
}
.plan.active {
display: block;
}
.controls {
display: block;
}
}
</style>
<div class="price-charts">
<div class="controls">
<button class="plan-button" data-target="#planA">
Plan A
</button>
<button class="plan-button" data-target="#planB">
Plan B
</button>
<button class="plan-button" data-target="#planC">
Plan C
</button>
</div>
<div class="charts-wrapper">
<div id="planA" class="active plan">
<!-- Plan HTML -->
<p> Plan A </p>
</div>
<div id="planB" class="plan">
<!-- Plan HTML -->
<p> Plan B </p>
</div>
<div id="planC" class="plan">
<!-- Plan HTML -->
<p> Plan C</p>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E="
crossorigin="anonymous"></script>
<script>
(function ($) {
$(".plan-button").click(function () {
// Make all plans inactive
$(".plan").removeClass("active");
// Make corresponding plan active
$($(this).data('target')).addClass("active");
})
})(jQuery)
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment