I need to know if here's a way to make an element appear and disappear when I click another element. I'm working with Divi, so I can't edit the HTML source. I can add CSS and Java Script f needed.
What I want to achieve is this:
When I click on my <h2 class="entry-title">, the <div class="post-content"> should appear and disappear on every click.
<article id="post-301">
<h2 class="entry-title">Best Practices</h2>
<div class="post-content"><div class="post-content-inner et_pb_blog_show_content">
<p>The ten central child protection steps through which organizations will progress as part of the Aleinu campaign.</p>
</div></div>
</article>
I tried adding this script, but didn't work at all:
<script>
jQuery(function ($) {
$( document ).ready(function() {
$(".entry-title").on("click", function(){var x = document.getElementsByClassName(".post-content");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
};
});
});});)
</script>