Solved

Jquery first child

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

21 Experts available now in Live!

Get 1:1 Help Now