enltr xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"http://www.w3.org/1999/xhtml/vocab/////////////////Get the parent of childnode using .parent() | BitsyCodehttps://www.bitsycode.com/methods/dom/parentGet the parent of childnode using .parent() | BitsyCode Get the parent of childnode using .parent() | BitsyCode html not-front not-logged-in no-sidebars page-node page-node- page-node-58 node-type-page

Get the parent of childnode using .parent()

container

.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.
Share

Developed and built with passion and commitment.
Maintained by the bitsycode team.