I am using a JQuery UI dialogue and it renders the below HTML. I want the span tag to be replaced with H2 tag, do we have any way to do this
<div class="ui-dialog-titlebar ui-widget-header">
<span class="ui-dialog-title" id="ui-id-20">
</span>
I am using the Jquery UI 1.11
Please consider the following example, based on https://api.jqueryui.com/1.11/dialog/#entry-examples
$(function() {
$("#dialog").dialog({
autoOpen: false,
create: function(e, ui) {
var w = $(this).dialog("widget");
var t = $(".ui-dialog-title", w);
var h2 = $("<h2>", {
id: t.attr("id"),
class: t.attr("class")
}).html(t.text());
t.replaceWith(h2);
}
});
$("#opener").click(function() {
$("#dialog").dialog("open");
});
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<button id="opener">open the dialog</button>
<div id="dialog" title="Dialog Title">I'm a dialog</div>
Please see:
https://api.jqueryui.com/1.11/dialog/#event-create
You can inject your own code or elements during the create
callback.