JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 21st, 2012, 01:55 PM
activestate activestate is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 activestate User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 47 sec
Reputation Power: 0
jQuery - How select only one ( that is in div, which start action )

Hello,
i have three div's and every div has hidden child (display none)
when i write:

$('.link img').click(function() {
$('.hidden').css({'display':'block'})
});

Something like this works, but then ALL .hidden appears, and i want to show only .hidden that is in clicked img. (current hidden not all hidden )



<div class="link"><p>show menu</p>
<a href="#"><img src="images/icons/arrow.png" /></a>
<div class="hiddenDiv"></div>
</div>

<div class="link"><p>show menu</p>
<a href="#"><img src="images/icons/arrow.png" /></a>
<div class="hiddenDiv"></div>

</div> <div class="link"><p>show menu</p>
<a href="#"><img src="images/icons/arrow.png" /></a>
<div class="hiddenDiv"></div>
</div>

Thanks for help, because i have all the time problems with wthis approach, where ia want to select current item not all items.

Can u explain me how it works, i dont need ready solutions, but explanation..

THANK You all for any help.

Mike.

Reply With Quote
  #2  
Old October 23rd, 2012, 10:15 AM
leonvv leonvv is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 24 leonvv User rank is Sergeant (500 - 2000 Reputation Level)leonvv User rank is Sergeant (500 - 2000 Reputation Level)leonvv User rank is Sergeant (500 - 2000 Reputation Level)leonvv User rank is Sergeant (500 - 2000 Reputation Level)leonvv User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 h 47 m 48 sec
Reputation Power: 0
Not sure, ( because I haven't tested it )
but I think this works:

$('.link img').click(function() {
$(this).find('.hidden').css({'display':'block'});
});

The $(this) line returns the element that triggered the event.
The .find() method will take a selector as parameter and search the descendants of the $(this) element.
So in fact it searches for an element with a class of hidden inside the children of $(this).
Then jQuery will set the display of all that elements to 'block'.

Let me know if it works !

Léon

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > jQuery - How select only one ( that is in div, which start action )

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap