I'm having some issues figuring out why my click function isn't working.
I have a JSFiddle for it here: http://jsfiddle.net/adbakke/ve9oewvh/
My html breaks down like so (condensed for posting here):
<div class="projectDisplay"></div>
<div class="flex-grid project-list">
<div id="project1" class="project">
<div class="projectImg"><img></div>
<div class="projectDesc">
<h3>title</h3>
<p>Description</p>
<span>click to close</span>
</div>
</div>
Now my JQuery gets all that HTML under "project" like so:
$('.project').click(
function() {
var newGet = $(this).html();
Then there's a bunch of functions (that all work beautifully) to add this data to <div class="projectDisplay"></div>
, and replace it all if there's already something there.
Then when I want to close the project by hitting <span> click to close</span>
, it works fine when I click the first item, but if I click a second before closing it does not work.
Edit: Click one image, then (before hitting close), click a second image in the project list, and then attempt to click "close project".
My close function looks like so:
$('.closeMe').click(
function() {
$('.projectDisplay').fadeOut(500);
}
);
I have tried putting it both inside and outside the scope of my click function itself. Neither will allow me to have it close upon clicking a second time to open up a different project.
What am I missing?
Update: Updated JSFiddle base so you can tell the different sections are different.