How to keep a dynamically created element on page with jQuery? When I refresh or go back to the page, the element is removed.
How to keep a dynamically created element on page with jQuery? When I refresh or go back to the page, the element is removed.
Using jQuery you can manipulate the element when creating the page, for example:
$(document).ready(function() {
$("#minhaDiv").html('<div id="NovaDiv"></div>');
$("#minhaDiv").append('<div id="OutraDiv"></div>');
});
Using pure javascript:
<script type="text/javascript">
function carregarDados() {
var divSelecionada = document.getElementById('minhaDiv');
divSelecionada .innerHTML = '<ol><li>Lista de Exemplo</li></ol>';
}
</script>
<body onload="carregarDados();">
<div id="minhaDiv"></div>
</body>