jqueryexample.com jQuery show/hide elements another page - jqueryexample.com

jQuery show/hide elements another page by jqueryexample

In normal FAQ pages when user click the question we can easily reach related answer div through named anchor.

Suppose we have a product page which has two div containts details, and according to the link clicked from previous page we show hide respective div.

In page one body part :
<body>
<a href="named-anchor.html#product1">Product1</a>
<a href="named-anchor.html#product2">Product2</a>
</body>

In page two :
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var locationHas = window.location.hash;
$(locationHas).show();
<body>
<div id="product1" style="display:none">Product1 details</div>
<div id="product2" style="display:none">Product2 details</div>
</body>
</html>

Did you like this? Share it:

Discussion

No comments yet, be the first.

Leave a Comment