JSFiddle - React, Tailwind, and code Playground
HTML
<div id="t">
<a class="xx">xx</a>
<a class="yy">yy</a>
<a class="zz">zz</a>
</div>
JavaScript
jQuery(document).ready(function($){
var html = '';
$('#t a.xx, #t a.zz').each(function(){
html += $(this).wrap('<p/>').parent().html();
$(this).unwrap();
});
alert(html);
});