views:

25

answers:

1

Hi all, so I'm having a bit of trouble getting a certain div to show onclick. Any takers?

HTML

<div style="float:left;width:40px;">
<span class="productControl" style="position:relative;">
    <div class="productMenuHolder" style="display:none;">
    <ul class="productMenuList">
        <li class="productMenuItem">Add to Collection</li>
        <li class="productMenuItem">Share</li>
    </ul>
    </div>
</span>
</div>

jQuery

$("span.productControl").click(function(){
    $(this).next().show();
});

The productMenuHolder doesn't seem to show up!

+3  A: 
$(this).find('.productMenuHolder').show()

I suggest you look a bit closer at the markup.

meder
Thank you @meder. Why does .next not work? (I will accept your answer, but stack will let me do it in 9 min)
st4ck0v3rfl0w
next means next sibling, not child. span owns div.
meder
Ahh...stupid stupid stupid ::hitting head with hands::As a follow up, how would I make the popup div hide when someone clicks anywhere but the productMenuHolder div?
st4ck0v3rfl0w