I have a legend
that when I load the page is opened by default and what I need is the opposite, that when loading the page is hidden and if I need to open it click.
My code is:
$(function() {
// Set cursor to pointer and add click function
$("legend").css("cursor", "pointer").click(function() {
var legend = $(this);
var value = $(this).children("span").html();
if (value == "[-]")
value = "[+]";
else
value = "[-]";
$(this).siblings().slideToggle("slow", function() {
legend.children("span").html(value);
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<legend class="section" style="color:#0CF">Contact Info <span>[-]</span></legend>