I added the following code to expand/collapse a Div by clicking on an image. this works well, but one problem is that the Div is shown by default, and I need to change the JS code, so that, the Div will be hidden by default, and only become visible when clicking on the image. If possible, please also help me on how to adjust the speed in which the Div expands or collapse.
function toggle5(showHideDiv, switchImgTag) {
var ele = document.getElementById(showHideDiv);
var imageEle = document.getElementById(switchImgTag);
if (ele.style.display == "block") {
ele.style.display = "none";
imageEle.innerHTML = '<img src="https:/PublishingImages/env3.png">';
} else {
ele.style.display = "block";
imageEle.innerHTML = '<img src="Supplier_Compliance/PublishingImages/env3.png">';
}
}
<div id="headerDivImg">
<a id="imageDivLink" href="javascript:toggle5('contentDivImg', 'imageDivLink');">
<img src="https://teams.connect.te.com/sites/BPDev/PublishingImages/attention1.jpg">
</a>
</div>
<div id="contentDivImg" style="display: block;">This demo uses plus and minus images for hiding and showing your div dynamically via JavaScript.</div>