Note that there are some explanatory texts on larger screens.

plurals
  1. POTwo divs click event works only on one div
    text
    copied!<p>I'm using jquery and ajax to create a drawer (#DrawerContainer) and load content into it if I click a thumbnail in a gallery. My function is almost finished but I want to be able to close that drawer if I click again the opening button (now #current). </p> <p>Here is a jsfiddle of my code: <a href="http://jsfiddle.net/RF6df/54/" rel="nofollow">http://jsfiddle.net/RF6df/54/</a><br/> The drawer element appears if you click a square/thumbnail, it's the blueish rectangle. The current thumbnail is turned green.</p> <p>I added a button in my drawer (not visible in the jsfiddle) to close it. I use this part of code for this purpose and it's working like a charm.</p> <pre><code> // Close the drawer $(".CloseDrawer").click(function() { $('#DrawerContainer').slideUp() setTimeout(function(){ // then remove it... $('#DrawerContainer').remove(); }, 300); // after 500ms. return false; }); </code></pre> <p>Now I need my <code>#current</code> div to be able to close <code>#DrawerContainer</code> the same way <code>.CloseDrawer</code> does in the code above. <br/>Unfortunately adding a second trigger like this <code>$("#current,.CloseDrawer").click(function()</code> to my function isn't working... When clicking my "current" thumbnail, it just reopen the drawer instead of closing it...</p> <p>How can I modify my code to close my #DrawerContainer with the "current" thumbnail?</p> <p>Please keep in mind that I'm learning jquery, so if you can comment it could be of a great help. And please do not modify my markup or css, since everything works beside the closing part.</p>
 

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