Last Updated: February 25, 2016
·
1.636K
· ehsanpo

How to show content based on urls via JavaScript/jQuery

 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
 <script type="text/javascript">
 $(document).ready(function() {
var option = 'coke';
var url = window.location.href;
option = url.match(/option=(.*)/)[1];
showDiv(option);
 });
 function showDiv(option) {
$('.boxes').hide();
$('#' + option).show();
 }
 </script>