JSFiddle - React, Tailwind, and code Playground

HTML

<div id="container">
    <div id="thisShouldBeIgnored"></div>
    <div id="ignoreThisToo"></div>
    <div id="one">
        <div id="two">
            <div id="three">
                <a href="" class="anchor">Hello</a>
            </div>
        </div>
    </div>
</div>

JavaScript

var firstAnchor = $('#container a')[0],
    parentId = $(firstAnchor).parent().attr('id');

$(firstAnchor).html(parentId);