JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<div id='jqxMenu'>
<ul>
<li><a href="#">Home</a>
</li>
<li>About Us</li>
<li>Services</li>
<li>Product
<ul>
<li><a href="#">New</a>
<li>
</ul>
</li>
</ul>
</div>
<div>
<input style="margin-top: 20px;" type="button" id='jqxButton' value="Destroy" />
</div>
JavaScript
$("#jqxMenu").jqxMenu({
width: 450,
height: 30,
theme: 'energyblue'
});
$("#jqxButton").jqxButton({
height: '30px',
width: '120px',
theme: 'energyblue'
});
$('#jqxButton').on('click', function () {
$('#jqxMenu').jqxMenu('destroy');
$('body').html("<div id='jqxMenu'><ul><li> Dynamic Home<ul><li>Menu1</li></ul></li></ul></div>");
//removeAllAttrs($('#jqxMenu')[0]);
$("#jqxMenu").jqxMenu({
width: 450,
height: 30,
theme: 'energyblue'
});
});
//Tried to remove the all the attributes
function removeAllAttrs(element) {
for (var i = element.attributes.length; i-- > 0;)
if (element.attributes[i].nodeName != "id") {
element.removeAttributeNode(element.attributes[i]);
}
}