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:
read architecture overview.
add scripts directly popup:
<script src="jquery.min.js"></script> <script src="app.js"></script>
(the comment raises valid point) dom manipulation, wrap code in the
ready()
event:$(document).ready(function() { /* manipulate dom here */ });
Comments
Post a Comment