last-child Selector- jQuery


$( “:last-child” ) – selector is used to select the last child of its parent.


Syntax : last-child Selector- jQuery

last-child Selector- jQuery Example

<!DOCTYPE html>
<html>
<head>
<title>last-child Selector- jQuery Example</title>
 <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js">
 </script>
<script type="text/javascript">
         $(document).ready(function(){
         $("#demo").click(function(){
          $("ol li:last").css("border","4px solid red");
          $("ol li:last").css("color","blue");
          $("ol li:last").css("font-size","26px");
          });
          });
</script> 
  
</head>	
<body>
<a href="javascript:void(0)" id="demo"> 
Click Me
</a>
<ol>
  <li> First Item </li>
  <li> Second Item </li>
  <li> Third Item </li>
</ol>
</body>
</html>             

Try it »


Advertisements

Add Comment

📖 Read More