Solved

Jquery first child

Posted on 2014-07-25
4
315 Views
Last Modified: 2014-07-25
Hi,

I want to apply a click event to all child list items  in an undordered list other than the first child. how can i achieve this?

Thanks
0
Comment
Question by:coolispaul
  • 2
4 Comments
 
LVL 10

Expert Comment

by:aboo_s
ID: 40218801
Try The nextSibling property, which returns the node immediately following a given node!
0
 
LVL 13

Accepted Solution

by:
duncanb7 earned 500 total points
ID: 40219010
Do want to click to all its child nodes besides first child node ? If so, see the following code

Duncan
  $("#top li:not(:first-child)").click(
  function() {
  this.style.color="green"
  alert( "Clicking" );
}
  ); 

<ul id='top'>
 <li>First item</li>
 <li>Second item</li>
 <li>Third item</li>
</ul>

Open in new window

0
 

Author Comment

by:coolispaul
ID: 40219016
thats the one

great thanks
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40219024
Thanks for your points and all code for jquery

Have a nice day

Duncan
$("#top li:not(:first-child)").click(
  function() {
    $(this).css("color","green");
  alert( $(this).text() );
}
  ); 

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now