JSFiddle - React, Tailwind, and code Playground

HTML

<div class='jt-header'>a header</div>
<div class='jt-detail'>a detail
    <div class='jt-item-price'>12.34</div>
</div>
<div class='jt-header'>another header
    <div class='jt-item-price'>34.45</div>
</div>
<div class='jt-detail'>another detail</div>

CSS

.jt-header {
    background: #eee;
    padding: 10px;
    margin-top: 10px;
}
.jt-detail {
    background: #d8d8d8;
    padding: 10px;
}

JavaScript

$(".jt-detail .jt-item-price").each(function () {
    var price = $(this);
    var prevhead = $(this).parent(".jt-detail").prev(".jt-header");
    if (!prevhead.find('.jt-item-price').length > 0) {
        price.appendTo(prevhead);
    }
});