Changing content of last li element - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:jQuery Method Example

Description

Changing content of last li element

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.2.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){//ww  w. j ava2s.c  o  m
$('li:last').html('Buttermilk');
    });

      </script> 
   </head> 
   <body> 
      <ul> 
         <li>Coffee</li> 
         <li>Tea</li> 
         <li>Milk</li> 
      </ul>  
   </body>
</html>

Related Tutorials