2

I'm new on Browser Extension dev. I'm trying to do some easy stuff, but I don't really know why doens't work. What is the problem? I can't manipulate DOM of my popup.html file. Here an example:

<html>
<head>
 <script src="js/jquery.js"></script>
 <script src="js/main.js"></script>
</head>
<body id="content">
 <p> Hello world </p>
 <button id="go" />
</body>
</html>

And here my very simple main.js file:

$(document).ready(function() { 

 $('#go').click( function(){

    $( "#content" ).empty();
    alert("Done");
 });
});

After click, the content of my Body seems doesn't disappear, but if I put an alert, I can see that my code work (when the alert show). But after click() event (when I close the alert), the popup file it's restored and paragraph is still here.

So, what I'm doing wrong? Can I manipulate the DOM of my popup file? Or my JS code need fix? I've made some tests, and I notice that any event, any data and any action die after click() event. I've also try

location.href = "other_page.html"; 

the redirect work, but as I said after click I return in popup.html file.

Thanks, I'm here for more specification

Robert
  • 33
  • 3

1 Answers1

1

I had the same problem.... I think Edge doesn't like jquery click() function.

Try with this:

document.getElementById("logout").addEventListener("click", function() { 
$( "#content" ).empty();
alert("Done");
}

I've solved in this way :)

Aso Strife
  • 1,089
  • 3
  • 12
  • 31