When a user clicks on a button, I am loading an HTML file into a DIV (iframe).
The issue arises when the user clicks another button and wants to reload the iframe with a different HTML file.
This is the current code snippet:
<script type="text/javascript">
$(function(){
$('#2015').click(function(){
if(!$('#iframe').length) {
$('#content').html('<iframe id="iframe" src="2015.html" width="700" height="450"></iframe>');
}
});
});
</script>
Here is the button code:
<a href="#" id="2015">2015</a>
How can I remove the current content within the iframe before loading the next HTML file into it?