【发布时间】:2015-10-11 19:54:18
【问题描述】:
我正在构建我的第一个 chrome 扩展程序,但遇到了一些问题。我想在 popup.html 上使用 jQuery。弹出窗口可以正常工作,但 jQuery 不起作用。
编辑:我改了,这是新代码,还是不行。有任何想法吗?我花了两个多小时试图弄清楚。我是扩展的初学者,并且在 javascript 和 jquery 方面相当生疏,所以它肯定是一些小而令人尴尬的东西......非常感谢!
manifest.json
"content_scripts": [{
"matches": [website],
"js": [
"content.js",
"https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"]
}],
popup.html
<!DOCTYPE html>
<html>
<head>
<title>First Google Extension</title>
<style>
body {
font-family: "Segoe UI";
width: 300px;
font-size: 14px;
};
#changeMe {
color: blue;
font-style: bold;
};
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
Welcome to my first Google Chrome Extension! <br>
<div id="changeMe">
I'm different!
</div>
</body>
</html>
popup.js
$(document).ready(function() {
$("#changeMe").append("Test!");
});
【问题讨论】:
标签: javascript jquery google-chrome google-chrome-extension