Get first and last value of ul li using jQuery

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.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Get first and last value of ul li using jQuery

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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Removing index.php From Codeigniter URL htaccess
  2.   PHP Laravel carbon convert String To Date
  3.   Jquery Count Child Elements with class
  4.   jQuery DataTables Responsive Example
  5.   Laravel Delete Record using jquery Ajax Request
  6.   PHP E-Commerce Shopping Cart Application step by step
  7.   How to get nth-child Selector using Jquery
  8.   Laravel 5.6 Sending Emails using SMTP Tutorial
  9.   Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects
  10.   FontSpace Web Application Icons

Leave a Reply

Your email address will not be published. Required fields are marked *