I have a simple jquery script that shows and hides div block:
<script type="text/javascript">'
$(document).ready(function(){
$(".slidingDiv").hide();
$('.show_hide').click(function(){
$(".slidingDiv").slideToggle();
});
});
</script>
<a class="show_hide" href="#">Show/hide</a>
<div name="gohere" class="slidingDiv">
...
</div>
It’s working fine, but if the URL contains #gohere I want to automatically show this div and hide it only if .show_hide is clicked.
Set the divs ID to be gohere, then you can do:
since your href attribute will contain
#gohere, the selector for the slidetoggle will end up being#gohere, which corelates to your divs ID.EDIT:
for the first part of your question, you can get the current hash tag from
window.location.hash.You should probably put some better error checking in there, but it should work.