In buddypress have sort by option in members loop, We added class for members list for design purpose using jquery. When sort by changed from default sort the response will override our customisation by AJAX response.
I replaced "block" text by image URL using below script,
<script type="text/javascript">
jQuery('body .block-member a').each(function() {
var text = jQuery(this).text();
if(text == 'UnBlock'){
jQuery(this).html(text.replace('UnBlock', "<img src='http://localhost/resttest/images/unblock.png' />"));
}else{
jQuery(this).html(text.replace('Block', "<img src='http://localhost/resttest/images/block.png' />"));
}
});
</script>
Below view is my initial page load,
After order by changed image automatically override by admin-ajax.php response. like below,