1

I have an existing script that performs a function on my website when a button is pressed. Is there a way to make this button also show a div at the same time? When you visit the google homepage you are met with this; enter image description here Yet when you press google search you are met with this; enter image description here

I know this is a different page with a different url but is there a way to achieve this with show/hide div? I am not bothered about people disabling javascript because that is required for my system anyway!

JBithell
  • 627
  • 2
  • 11
  • 27
  • Why can't you add code to show/hide a div to your existing code? What is it about your existing code that prevents you from just adding in that extra functionality? – Zhihao Mar 07 '14 at 18:07

2 Answers2

0

I found the answer: jquery: change the URL address without redirecting?

document.location.hash = "show_picture";

Javascript can only control the stuff after #, that is also what google does. With this line you reset the stuff behind the #

Community
  • 1
  • 1
Nicky Smits
  • 2,980
  • 4
  • 20
  • 27
0

you can use jquery to get what you want and put the following code in button click event

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("#hide").click(function(){
    $("p").hide();
  });
  $("#show").click(function(){
    $("p").show();
  });
});
</script>
</head>
<body>
<p>If you click on the "Hide" button, I will disappear.</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
</body>
</html>
Eanthmue
  • 471
  • 2
  • 5