Get or Set text of element with .text()

.text()


Description: Get the text content for the first matched element or you can set one or more text content for every matched element.


Example:

<!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>text demo</title>
      <script src="http://code.bitsycode.com/bitsycode-latest.min.js"></script>
    </head>
    <body>
      
      <div></div>
      
      <script>
         
         bitsyCode.ready(function(){
            bitsyCode('div').text("This text content that has been added through BitsyCode"); // SET TEXT
            
            var divTEXT = bitsyCode('div').text(); // RETRIEVE TEXT
            
            
         })
         
      </script>
     
    </body>
    </html>

Preview:

This text content that has been added through BitsyCode
  • Usage

    • How to use:

      Set or Get the text content of an element using .text().

    • USAGE:

      bitsyCode('element').text("your TEXT content here");
  • Options

    • What options are there:

      There are no options for this method.

  • Returns

    • specifying text() with no specified text content, will return the text of the element.
Share