Hiding the 'x' button on Dialog

Hiding the 'x' button on Dialog

<span class="Apple-style-span" style="border-collapse: collapse; ">Hi
I want to hide the 'x' button on the dialog dynamically.
Is there a good way to do it? or is there a setting? i couldnt find one.
All i can think of is doing something like
$(".ui-dialog-titlebar-close").css("display", "none");
However I dont think this is a good way. And if i have more than one dialog on the page then all 'x' buttons will disappear.</span><div>
<span class="Apple-style-span" style="border-collapse: collapse; ">
It is true that if I want to hide it, its most likely that I will want hide it on every dialog instance and therefore i can chance the css directly.</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; ">However, what if I really need to do it dynamically?
</span><div><span class="Apple-style-span" style="border-collapse: collapse; ">
Thanks</span>
</div></div>