homepage Welcome to WebmasterWorld Guest from 54.197.65.82
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
jQuery is kicking my ass
Sub_Seven



 
Msg#: 4495320 posted 8:10 pm on Sep 14, 2012 (gmt 0)

Hello people, when I come here is because I'm already desperate, frustrated and about to start kicking walls.

It pisses me off the fact that I can't seem to get a handle on jQuery for simple stupid things that should be easy.

Hoping to get someone to point me in the right direction, I have this code:

<div id="leftPanel">
<div>
<p>Cia Logo</p>
</div>
<dl>
<dt>Item 1</dt>
<dd>Subitem 1</dd>
<dd>Subitem 2</dd>
<dd>Subitem 3</dd>
<dd>Subitem 4</dd>
<dd>Subitem 5</dd>
<dt>Item 2</dt>
<dd>Subitem 1</dd>
<dd>Subitem 2</dd>
<dd>Subitem 3</dd>
<dd>Subitem 4</dd>
<dd>Subitem 5</dd>
<dt>Item 3</dt>
<dd>Subitem 1</dd>
<dd>Subitem 2</dd>
<dd>Subitem 3</dd>
<dd>Subitem 4</dd>
<dd>Subitem 5</dd>
</dl>
</div>


and this jquery to slide down the dds when you mouseover their dt:

<script>
(function() {
$('#leftPanel dd').hide();
$('#leftPanel').on('mouseenter', 'dt', function() {
$(this).nextUntil('dt').slideDown();
});
})();
</script>


If you mouseover on any of the dts it works fine, it slides down all the dds BUT *BUT* what I cannot figure out is how to tell jQuery to hide all dds that are not under $(this) dt.

I thought something like this should do the trick:

$(!this).children('dt').slideUp(); or this
$!(this).children('dt').slideUp();

But obviously it is not that simple.

Could anyone PLEASE get me out of my misery?

Thanks.

 

nettulf



 
Msg#: 4495320 posted 7:38 pm on Sep 15, 2012 (gmt 0)

Yes, it is that simple. :) You just had the syntax a bit wrong:

Try this after slideUp:

$('#leftPanel dt').not(this).nextUntil('dt').slideUp();
Sub_Seven



 
Msg#: 4495320 posted 11:49 pm on Sep 15, 2012 (gmt 0)

I'll be damned nettulf, it was that simple.

I keep thinking the syntax of PHP should apply for other languages, I was completely unaware of the existence of not().

I thank you a lot for the help, and welcome to the forum by the way.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved