Select all childs except first using JQuery

Select all childs except first using JQuery

Hello Sir

I Have following code :

<ul>
 <li>First item</li>
 <li>Second item</li>
 <li>Third item</li>
</ul>

And i need to add a class to 2nd & 3rd element or child as follows :

<ul>
 <li>First item</li>
 <li class="NewClass">Second item</li>
 <li class="NewClass">Third item</li>
</ul>

Please reply with code.

Thank you in advance.

View Answers

December 14, 2010 at 5:15 PM

Its very simple Just use the following code line :

$("li:not(:first-child)").addClass("NewClass");









Related Tutorials/Questions & Answers:
Select all childs except first using JQuery
Select all childs except first using JQuery  Hello Sir I Have following code : <ul> <li>First item</li> <li>Second...; <li>First item</li> <li class="NewClass">Second item<
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Hii Sir, Lots of thnx to ur reply .I went through both... of selecting value from autocomplete textbox using jquery in jsp from mysql database
Advertisements
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Sir, Lots of thnx to ur reply .I went through both the tutorials... autocomplete textbox using jquery in jsp from mysql database. Kindly send me
validate select option jquery
validate select option jquery  How to Validate select option in JQuery
select query using hibernate
select query using hibernate  Hi, can any one tell me to select records from table using hibernate. Thanks   Please visit the following link: Hibernate Tutorials The above link will provide you different
jQuery to Select Multiple CheckBox
jQuery to Select Multiple CheckBox       In this first jQuery tutorial we will develop a simple... to develop the Select Multiple CheckBox  program Step 1: Create php file
jQuery to Select Multiple CheckBox
jQuery to Select Multiple CheckBox       In this first jQuery tutorial we will develop a simple... to develop the Select Multiple CheckBox  program Step 1: Create php file
Vertical news slider using jquery
Vertical news slider using jquery  how to creatw vertical news slider using jquery Sorry for wrong category but i cant get my jquery category
HTML form validation using jquery
HTML form validation using jquery  Is there any way for validating html elements common under a class by giving its class name in jquery validation code..that means validating all elements by using its class name if those
Show Limited Data Using jquery
Show Limited Data Using jquery  How to show limited results in JQuery... it using JQuery?   See the JQuery example to show the limited fetch results in JQuery. var comments = $('.description_text').size(); if (comments >
Use of jQuery attribute filters
will learn how to use attribute filters of jQuery.ADS_TO_REPLACE_1 Using jQuery...; attribute of html DOM : Using it , you can hide all the link in your html page... Use of jQuery attribute filters   
JQuery
- $(':input').parents(':not(:first)').show() would show all the parents of every input element except the first parent. 4. The ready made plug-in reduces overhead from...JQuery  hi there, I am just beginner for jQuery and i want
Using the QUnit to test jQuery application
Using the QUnit to test jQuery application       Using the QUnit to test jQuery application Using Qunit , testing of JQuery become very easy and efficient
Disabling submit button using jQuery
Disabling submit button using jQuery  Hello Sir I want to know - is there any way or approach to disable client side form's "Submit" button. Please give code also.ADS_TO_REPLACE_1   For all submit buttons, via JQuery
Html form validation using jquery
Html form validation using jquery  Hi i am using form with html. Form elements like textbox, radio,checkbox,listbox i was used now how to validate the elements using submit jquery option
Using the jQuery Transform plug-in(XSLT)
Using the jQuery Transform plug-in(XSLT)       Using the jQuery Transform plug-in(XSLT... Language Transformations ). The jQuery Plugin we are using
Form validation Using Jquery Plugin
Form validation Using Jquery Plugin  Hello sir I want to implement form validation using JQuery Plug-in. My code is : <html> <style type...;/form> </body> </html> Please provide me JQuery code regarding
jQuery auto complete through database using JSP shows error
jQuery auto complete through database using JSP shows error  The tutorial on jQuery titled "jQuery auto complete through database using JSP" shows error on browser when I try to select the one in the dropdown. Please help
application using AJAX and JQuery and also use JSP
application using AJAX and JQuery and also use JSP   i need create an application using AJAX and JQuery and also use JSP
Using the jQuery event object
Using the jQuery event object       Using the jQuery event object JQuery... to these standards, this system normalize the event object. jQuery. Event
Find Browser & it's version using jQuery
Find Browser & it's version using jQuery  Hi sir I heard that JQuery have some method which can be used to find the Browser name & its version. I need the code which checks the browser and if it is "Mozilla", it will show
How to write a search functionality using javascript/jquery
How to write a search functionality using javascript/jquery   How to write a search functionality using javascript/jquery for ex: im searching "s" names it wil display "s" names
ModuleNotFoundError: No module named 'pid-childs'
ModuleNotFoundError: No module named 'pid-childs'  Hi, My Python... 'pid-childs' How to remove the ModuleNotFoundError: No module named 'pid-childs' error? Thanks   Hi, In your python environment you
jQuery change event with multiple select option
jQuery change event with multiple select option In this tutorial , we will discuss about 'change' event of jQuery with multiple select list & it also display the selected option. In the below example a multiple select list
how to operate on select box using ajax in struts2?
how to operate on select box using ajax in struts2?  I am doing a project on struts2 in which i have a jsp page which has two select boxes like <... so that when i select a district value it will retrieve me all the blocks under
jquery highlight textbox using jQuery
Content highlighting using jQuery In this section , you will learn how to highlight input row or group of input row using jQuery. In the below given example...;Content highlighting in form using jQuery - Example</title> <style>
how to operate on select box using ajax in struts2?
how to operate on select box using ajax in struts2?  I am doing a project on struts2 in which i have a jsp page which has two select boxes like... it will retrieve me all the blocks under it by assigning to the block list select
Crop image Using JQuery, servlet or JSP.
Crop image Using JQuery, servlet or JSP.  Hi sir I need the code of Cropping image using JQuery with the help of servlet or JSP. I need both the code Client side as well as of server side. Please Help me
Test hidden element using JQuery
Test hidden element using JQuery  Suppose i have an element which i am hiding and showing, using .hide(), .show() or .toggle().How do you test to see... using following code snippet :ADS_TO_REPLACE_1 $(element).is(":visible") Hope
Implementing Digits restriction Using JQuery
Implementing Digits restriction Using JQuery  Hi Sir I have following field in my html form : <div>Age<input type="text" name="quantity.... Please provide code.   You can implement these two things using ASCII code
Replace broken Image using JQuery
Replace broken Image using JQuery  Sir My web page contains a lot of images. But when it will not loaded properly, it shows a broken image. How can I fix it so that broken image will be replaced by error image automatically
jQuery 'select' form event
jQuery 'select' form event In this tutorial, we will discuss about 'select ' form event to display message when we select something inside input box. In this Example, two input text box are given , when we select
check username availability using JSP & JQuery
check username availability using JSP & JQuery  Hi sir I want check username availability using JSP & JQuery. Please add code with your answer. Thnks in advance
SELECT query using executeUpdate() instread of executeQuery()
SELECT query using executeUpdate() instread of executeQuery()  can we execute SQL SELECT query using executeUpdate() instread of executeQuery() method   Hi Friend, No, You cannot. Thanks
Auto grow Text Area using jQuery plug-in
Auto grow Text Area using jQuery plug-in  Hi sir How can we make a textarea auto grow ? What is the name of the plug-in used for auto grow text area. Please mention code with your reply
JQuery
to select option using key-board (means using key-down...JQuery  how to create jquery auto-complete textbox ? in which data...://www.roseindia.net/tutorial/jquery/autoSuggestTextbox.html   thank you
Selecting value from autocomplete textbox using jquery in jsp
Selecting value from autocomplete textbox using jquery in jsp   hello Sir, I completed ur tutorial on autocompletion textbox from database using Jquery in jsp .It worked Fine .Thank you For Ur valuable Guidance .But it does
Selecting element using jQuery.
Selecting element using jQuery In this tutorial , we will discuss about the different methods to select elements of html page. The jQuery has two ways to select elements. The first uses a combination of CSS and XPath selectors passed
SELECT query using executeUpdate() instread of executeQuery()
SELECT query using executeUpdate() instread of executeQuery()  for Ex...{ st.executeUpdate("select * from EMP"); //gives us Exception... executeUpdate() method with select quesry then you can't be able to retrieve data from
Hide hyperlink using jQuery
Hide hyperlink using jQuery In this tutorial, we will discuss about how to hide hyperlink after clicking it using jQuery. In the below example , a hyperlink "Click here to hide this link" is included in the web page. When we
Insert text into database table using JSP & jQuery
Insert text into database table using JSP & jQuery In this tutorial , the text is inserted into database table using JSP & jQuery. In the below example, the first JSP page is use to display text box in which we type data
Getting the ID of the element that fired an event using JQuery
Getting the ID of the element that fired an event using JQuery  Hello sir I want to know-Is there any way to get the ID of the element that fires... friend In jQuery event.target always refers to the element that triggered
Select Records Using Prepared Statement
Select Records Using Prepared Statement   ... to select some specific records by using the PreparedStatement. We know...\jdbc\PreparedStatement>java SelectRecords Select Records Example by using
how to validate the telephone number without using jquery in html with javascript
how to validate the telephone number without using jquery in html with javascript  how to validate the telephone number without using jquery in html with javascript
jQuery image replacement by click or select
jQuery image replacement by click or select In this section, you will learn... or reloading complete page. This will be done using jQuery. You need only jQuery set up file. In the below example, we are using jQuery setup file 
Hide boxes by clicking on it using jQuery
Hide boxes by clicking on it using jQuery In this tutorial , we will discuss about how to hide boxes by clicking on it using jQuery. In the given below... is created using 'html' and it is replicated by using "for " loop
jQuery - jQuery Tutorials and examples
to Select Multiple CheckBox In this first jQuery tutorial we will develop a simple... Demos:ADS_TO_REPLACE_2 We have created many examples of using jQuery. View the demo's here. Learn jQuery step by step using the following tutorials
Position one element relative to other using JQuery.
Position one element relative to other using JQuery.  Hello Sir In my web page, i have a hidden div which contains a toolbar-like menu. Also, i have a number of divs which are enabled to show the menu DIV when the mouse hovers
select result from three tables using sql.
select result from three tables using sql.  I want to get a result from three tables. i dont how to write the sql query. Please help me. "I want to display Name,Username and Product_Name where Id=007" table "register" Name
Creating, getting, and setting content using jQuery
Creating, getting, and setting content using jQuery... content using jQuery Using jQuery , you can add(create) html content... You can get the html by using jQuery and also can modify

Ads