Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

Jquery first child

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
coolispaul
Asked:
coolispaul
  • 2
1 Solution
 
aboo_sCommented:
Try The nextSibling property, which returns the node immediately following a given node!
0
 
duncanb7Commented:
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
 
coolispaulAuthor Commented:
thats the one

great thanks
0
 
duncanb7Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now