Get the last childnode of a element with .last()

.last()


Description: Get the last childnode of a element.


Example:

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>last demo</title>
      <script src="http://code.bitsycode.com/bitsycode-latest.min.js"></script>
    </head>
    <body>
      
      <ul>
         <li>One</li>
         <li>Two</li>
         <li>Three</li>
      </ul>
      
      <div class="result"></div><br />
      
      <button onclick="last()">Get .last() text</button>
      
      <script>
        
        function last() {
            var result = bitsyCode("ul").last().text();
            bitsyCode(".result").text(result);
        }
         
      </script>
     
    </body>
    </html>

Preview:

  • One
  • Two
  • Three

  • Usage

    • How to use:

      Get the last childnode of a element.

    • USAGE:

      bitsyCode("element").last()
  • Options

    • What options are there:

      There are no options for this method.

  • Returns

    • Returns: Last childnode of a element
Share