javascript - Toggle display-state with jQuery -


I want to toggle the visibility of a div through jQuery's CSS, but it seems that it's working Stops something for The device has a Google map which I am also starting, but I do not think this is a problem.

Javascript:
  Initialize the function () {var map; Var map option = {zoom: 8, center: new google.maps.LatLng (-34.397, 150.644), type the map: google.maps.MapTypeId.ROADMAP}; Map = new google.maps.Map (document.getElementById ('map_canvas'), map options); } $ ("Show-map") .click (function () {$ (". Display-toggle"). Css ("display", "block"); initialize ();}); $ ("# Hide-map"). Click (function () {$ (". Display-toggle"). CSS ("Display", "None");});   

CSS:
  #map_canvas {height: 100%; Border: 1px solid red; }. My-map-section {Display: Block; Height: 200 pixels; Width: 100%; }. Display-toggle {display: none; }   

HTML:
  & lt; Script src = "https://maps.googleapis.com/maps/api/js" & gt; & Lt; / Script & gt; & Lt; Div & gt; & Lt; Form id = "myform" & gt; & Lt; Input id = "show-map" type = "button" value = "show map" & gt; & Lt; / Input & gt; & Lt; Input id = "hidden-map" type = "button" value = "hide map" & gt; & Lt; / Input & gt; & Lt; / Form & gt; & Lt; / Div & gt; & Lt; Div class = "section my-map-section display-toggle" & gt; & Lt; Div id = "map_canvas" & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

You should put your clickhandlers inside a document. See the handler first

  $ (document) .ready (function () {$ ("# show-map"). Click (function () {$ ("display-toggle Click "(function () {$ (". Display-toggle "). CSS (" display "," block "); start ();}); $ (" # hide-map "). "Display", "none");});});    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -