Is there a reason I can't access the children()
element I'm appending?
This code adds default color blue color
to all tags on this question page.
$(document).ready(() => {
$.each($('li.d-inline.mr4.js-post-tag-list-item'), function() {
const e = $(this);
const h = `<span id="span1">default color <span id="span2">blue color</span></span>`;
var el = e.find('#span1');
if (el.length === 0) {
e.append(h);
el.children().css({
'color': 'blue',
'font-style': 'italic',
'font-weight': 'bold'
});
console.log.apply(console, el);
}
});
});
<!-- put some HTML here, please -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>