Chrome扩展程序更改了弹出背景而不是正文

时间:2019-01-15 20:42:56

标签: google-chrome-extension

为什么我不能更改主体背景颜色?该扩展程序正在更改弹出的背景颜色

我所拥有的是:

manifest.josn

{
  "manifest_version": 2,

  "name": "Tuter",
  "description": "This intents to change body bg.",
  "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">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="bootstrap.min.css">
  </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>

在popup.js中,我有

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

0 个答案:

没有答案