homepage Welcome to WebmasterWorld Guest from
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

Toggle DIV when multiple divs exist

 11:35 am on Aug 29, 2013 (gmt 0)

I always get confused with this!

I have the following:

<ul class="actions">
<li class="video icn"></li>
<li class="settings icn">
<ul class="settings-menu">
<li>Always Decline</li>
<li class="close icn"></li>

And I need it so when the user clicks on the .settings list item it then adds the class of .open to the .settings-menu unordered list.

I have the following:

$(".settings.icn").click(function () {

Which works but if there's more than one of these on the page then it adds the class to all on the page. I've therefore tried the following but they don't work:

$(".settings.icn").click(function () {

$(".settings.icn").click(function () {

Any ideas would be much appreciated.



 12:44 pm on Aug 29, 2013 (gmt 0)

Got it!

Should be this:

$(".settings.icn").click(function () {


 4:55 pm on Aug 30, 2013 (gmt 0)

Glad you got it sorted, greencode! And thank you for posting back with your solution. :)

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