Today, We want to share with you Get first and last value of ul li using jQuery.In this post we will show you jQuery first() and last() functions example, hear for Remove li elements of ul except first and last in jQuery we will give you demo and example for implement.In this post, we will learn about How to get only the first list element in menu of unordered list in JQuery? with an example.
Get first and last value of ul li using jQuery
Contents
There are the Following The simple About jquery get last element of array Full Information With Example and source code.
As I will cover this Post with live Working example to develop jquery last-child with class, so the jquery insert after last child is used for this example is following below.
jQuery first() and last() functions example
index.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Get First and Last Element of li and option</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $(function() { //list-items example alert($("#aims li:first-child").text()); alert($("#aims li:last-child").text()); //drop down example alert($("#information option:first-child").text()); alert($("#information option:last-child").text()); }); </script> </head> <body> <!-- list items --> <ul id="aims"> <li>honda</li> <li>dreams yuga</li> <li>activa</li> </ul> <!-- Drop Down --> <select id="information"> <option>laptop</option> <option>mobile</option> <option>LCD</option> <option>Dasktop</option> </select> </body> </html>
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about jquery last-child with class.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donβt forget to share.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.