Solved

Jquery first child

Posted on 2014-07-25
4
321 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
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 …

831 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