javascript - Unable to use jQuery in chrome extension -


i trying figure out why not able use jquery in extension, absolute beginner, in theory should job:

manifest

{     "manifest_version": 2,     "name" : "id",     "version" : "0.1",     "description" : "id",     "browser_action" : {         // "default_icon" : "icon.png",         "default_popup" : "popup.html",         "default_title" : "id"     },     "content_scripts": [ {         "js": [ "jquery.min.js", "app.js" ],         "matches": [ "http://*/*", "https://*/*"]     }] } 

popup.html

<!doctype html> <html> <head>     <title></title> </head> <body>  </body> </html> 

app.js

$("body").append("hello world"); 

yet see empty popup instead of "hello world"

you can't inject content scripts extension pages (popup included).

you need to:

  1. read architecture overview.

  2. add scripts directly popup:

    <script src="jquery.min.js"></script> <script src="app.js"></script> 
  3. (the comment raises valid point) dom manipulation, wrap code in the ready() event:

    $(document).ready(function() {   /* manipulate dom here */ }); 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -