kamome kamome - 7 months ago 19
Javascript Question

How to remove div contents

I would like to refresh the content of a div tag. I create a map using Openlayer3. In my web there is a button to render a map into a div tag but every time I clicked the button another map is created following the last map. The goal is to remove the map showed showed into the div and render the new one. How can I do that ?

I tried

$('map').empty();


to erase the old one and render the new one but doesn´t work

Answer
$('map').remove(); 

If you want to remove the old map and make a new one, just remove the old map.

Even better, do this

$(".youMapContainer").empty()
Comments