How to Expand/collapse WordPress posts with jQuery
-
I’m trying to integrate the jQuery code in this tutorial (https://wparena.com/how-to/how-to-expandcollapse-wordpress-posts-with-jquery/) so that the <!–more-> tag will expand the post within the page.
I’ve tried adding this to my header.php file, but so far not working.
<script type="text/javascript"> $(document).ready(function() { $(".post .entry-content").hide();? $(".post").after("<div class='openIt' style='border-top: 1px solid #666; color: #036; text-align:right; cursor:pointer;'>Expand</div>"); $(".openIt").click(function() { $(this).prev(".post").find(".entry").slideToggle("slow"); }); $(".openIt").toggle(function(){ $(this).html("Close")}, function(){ $(this).html("Expand") }); </script>
Am I making errors with syntax, or have I placed the javascript in the wrong place? Any help appreciated.
Cheers,
Martin White
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to Expand/collapse WordPress posts with jQuery’ is closed to new replies.