Get the parent of childnode using .parent()

.parent()


Description: Get the parent of the childnode.


Example:

<!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>parent demo</title>
      <style type="text/css">
          .yellow {
              background-color:yellow;
          }
      </style>      
      <script src="http://code.bitsycode.com/bitsycode-latest.min.js"></script>
    </head>
    <body>
      
    <div>
        <span class="myspan">This is a span.</span>
    </div>
    
    <script type="text/javascript">      
        
        bitsyCode.ready(function(){
            bitsyCode(".myspan").parent().addClass("yellow");
        })
        
    </script>
     
    </body>
    </html>

Preview:

This is a span.
  • Usage

    • How to use:

      Get the parent of the childnode

    • USAGE:

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

    • What options are there:

      There are no options for this method.

  • Returns

    • Returns: parent node of childnode.
Share