Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 16240

How do you remove all content within an element including the javascript

$
0
0

I'm using ajax to get the content (html, css, javascript) from another file. Everything works perfected initially; however, if I run this ajax request a second time, all the javascript from the first call remains saved on the dom, so any .on("click") functions get executed twice. I've tried $("#contentHolder").empty() with no success. Also, I do need to execute the ajax call more than once (I can't call it once, save the content, then just .hide/.show as needed).

$.ajax({    type: "GET",    url: "page.php",    dataType: "html",    success: function(data){        $("#contentHolder").html(data);    }});

Viewing all articles
Browse latest Browse all 16240

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>