JSFiddle - React, Tailwind, and code Playground

HTML

<div class="myDialog" title="Initial Title">
    This is the dialog
</div>
<button id="changeTitle1">Change Title With Function</button>
<button id="changeTitle2">Change Title With Plugin</button>

JavaScript

function setTitleWithPrefix(selector, title) {
        $(selector).dialog('option', 'title', 'xxx' + title);
    }

$.fn.dialogTitleWithPrefix = function(title) {
     this.each(function() { 
         $(this).dialog('option', 'title', 'xxx' + title);
     });
};

$('.myDialog').dialog({ autoOpen: true });

$('#changeTitle1').click(function() {
    setTitleWithPrefix('.myDialog', 'New Title With function');
});

$('#changeTitle2').click(function() {
    $('.myDialog').dialogTitleWithPrefix('New Title With plugin');
});