Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand correctly, the code you posted already does what you want, and you want to understand in detail what's going on, yes?</p> <p>So:</p> <pre> $(document).ready(function() { ... } </pre> <p>This means that the enclosed code (inside the brackets) should be executed when the page has finished loading.</p> <pre>$("#related2").slideDown();</pre> <p>This makes the selected element to show up using a slideDown effect. Since this is inside (document).ready, this happens as soon as the page finishes loading, and presumably the element is hidden before that (with CSS).</p> <pre> $(".close2").click(function(event) { ... }); </pre> <p>This attaches all elements with the class ".close2" a click event, so whenever these elements are clicked, the enclosed code is executed. Again, since this is inside the (document).ready block, this click event is attached as soon as the page finishes loading.</p> <pre> event.preventDefault(); </pre> <p>This makes it so that if the element already has a default event attached it is not executed (e.g., a link - - will already have a click event attached, so that when it is clicked the browser is taken to the url on the href). The behaviour of this method will depend if the element actually has a click event attached or not, in this case. It may well do nothing.</p> <pre> $("#related2").slideUp(); </pre> <p>Slides up the selected element.</p> <p>EDIT: Ok, just noticed your comment on your original post. It's not sliding down by default probably because the element is not hidden by default, which is required since the slideDown method really just "unhides" and element using a fancy effect. So you have to hide #related2 using CSS, or with inline style on the HTML. Which translates to either:</p> <pre><code>#related2 { display: none; } </code></pre> <p>on the CSS, or:</p> <pre><code>&lt;div id="#related2" style="display:none;"&gt;&lt;/div&gt; </code></pre> <p>on the HTML (of course, I'm presuming the element is a div).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload