无法在Chrome Extionsion中的活动标签中定位DOM

时间:2017-11-09 21:16:18

标签: google-chrome-extension google-chrome-devtools

您能告诉我为什么我无法在此扩展程序中将Active DOM定位到Active Tab中吗?

我拥有的是

的manifest.json

{
  "manifest_version": 2,

  "name": "Test",
  "description": "This extension is for Tets",
  "version": "1.0",

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },
  "permissions": [
    "activeTab"
  ],
    "background": {
        "scripts": ["jquery.min.js", "popup.js"],
        "persistent": false
    },
    "content_scripts": [{
        "js": ["jquery.min.js", "popup.js"],
        "matches": ["http://*/*", "https://*/*"]
  }]
}

在popup.html中我有

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
  </head>
  <body>
      <div style="padding:60px;">
        <button class="btn btn-default" >Button</button>
      </div>
    <script src="jquery.min.js"></script>
    <script src="popup.js"></script>
  </body>
</html>

最后我有

$("button").on("click", function(){
   $('body').css('background','red')
   console.log("Test");
});

这实际上是针对popup.html的正文并将.css()应用到那里。你能告诉我怎么解决这个问题吗?

0 个答案:

没有答案