Prevent reloading the page if there is something inside the div

0

How could I prevent reloading if something existed within a div ? and could it be prevented by making another div appear with the confirmation request instead of the alert of the javascript? I have no idea how I could do this.

    
asked by anonymous 16.06.2018 / 01:13

1 answer

2

As for reloading I find it hard to block this, the most you can block is the f5 key, but as far as checking the contents of the DIV I can help you.

You can use jQuery with the following code.

 if ($('div').html() !== ""){
    alert('Esta div possui conteudo');
    }
    else{
    alert('sta div possui conteudo');
    }
    
16.06.2018 / 01:45