Solved

Jquery first child

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Timer on div 5 22
selected value 16 23
Session on Html 8 36
[Bootstrap] Navigation Bar Collapse 27 32
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.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

680 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