I have a google map embedded in my page whose visiblity is set to hidden. Using a button i want to show the map on the page. Should be done using jquery.
my code - (not working)
<div id="map" style="height: 350px; border: 1px solid #979797;visibility="hidden";></div>
Anyone can help me with the related jquery codes?
jQuery Effect show() Method The show() method shows the hidden, selected elements. Note: show() works on elements hidden with jQuery methods and display:none in CSS (but not visibility:hidden).
To check if an element is hidden or not, jQuery :hidden selector can be used. .toggle() function is used to toggle the visibility of an element.
jQuery toggle() MethodThe toggle() method toggles between hide() and show() for the selected elements. This method checks the selected elements for visibility. show() is run if an element is hidden. hide() is run if an element is visible - This creates a toggle effect.
jQuery hide() Method The hide() method hides the selected elements. Tip: This is similar to the CSS property display:none. Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: To show hidden elements, look at the show() method.
Try
$('#map').css('visibility','visible');
Actually, if style has display:none
, you can use jquery function
$('#map').show();
Your style="" tag is also incorrect. You should have this: visibility: hidden;
Try this:
<div id="map" style="height: 350px; border: 1px solid #979797; display: none";></div>
$("#map").show();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With