1

I'd like to do the exact same thing as here Collapsing / hiding figures in R markdown, but instead of one image, I'd like to collapse several consecutive images all at once (using the same single button).

So far the following script, gets the desired result but just for 1 image:

<input type=button class=hideshow></input>
![](images/1.png) ![](images/2.png) ![](images/3.png) ![](images/4.png) ![](images/5.png)

<script>
$( "input.hideshow" ).each( function ( index, button ) {
button.value = 'Hide Output';
$( button ).click( function () {
var target = this.nextSibling ? this : this.parentNode;
target = target = target.nextSibling.nextSibling;
if ( target.style.display == 'block' || target.style.display == '' ) {
  target.style.display = 'none';
  this.value = 'Show Output';
} else {
  target.style.display = 'block';
  this.value = 'Hide Output';
}
} );
} );
</script>
Caterina
  • 775
  • 9
  • 26
  • 1
    Have you seen the second (most upvoted) answer to the question you linked? It gives you a way to wrap anything you like between html tags to collapse/hide. Another code folding option is using the details element as in https://stackoverflow.com/a/53870441/3430463 – 7hibault Jan 04 '19 at 09:10
  • The second answer you mentioned worked perfectly! Thanks :) – Caterina Jan 04 '19 at 09:22
  • @Caterina Happy to hear that you've found an answer, feel free to upvote the OP who had an answer for your question. Btw your question might be closed as a duplicate to groupd similar questions and help future users. – 7hibault Jan 04 '19 at 09:44

0 Answers0