Javascript Chrome扩展更改popup.html文本
我是一个完全的新手,我想从一个“p”标签中提取一个文本,然后把它放在另一个“p”标签中,这样当我点击我的分机时,我就会看到两个文本显示出来。 我做错了什么?我怎样才能避免将来犯类似的错误呢 popup.html:Javascript Chrome扩展更改popup.html文本,javascript,html,google-chrome-extension,Javascript,Html,Google Chrome Extension,我是一个完全的新手,我想从一个“p”标签中提取一个文本,然后把它放在另一个“p”标签中,这样当我点击我的分机时,我就会看到两个文本显示出来。 我做错了什么?我怎样才能避免将来犯类似的错误呢 popup.html: <!DOCTYPE html> <html> <head> <script type="text/javascript" scr= "popup.js"></script> </h
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" scr= "popup.js"></script>
</head>
<body>
<p id="firstText">this is the text to be repeated</p>
<p id= "secondText"></p>
</body>
</html>
manifest.json:
{
"manifest_version": 2,
"name": "test",
"description": "useless",
"version": "1.0",
"background": {
"scripts": [ "popup.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["http://*/*"],
"js": ["popup.js"]
}
],
"permissions": [
"activeTab","tabs", "http://*/*"
],
"browser_action": {
"default_popup": "popup.html"
}
}
使用此HTML弹出窗口:您有打字错误
src
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src= "popup.js"></script>
</head>
<body>
<p id="firstText">this is the text to be repeated</p>
<p id= "secondText"></p>
</body>
</html>
这是要重复的文本
如果这是准确的复制/粘贴,则在
中有一个打字错误。它应该是src
而不是scr
@ChrisP我很尴尬,非常感谢你的帮助!我使用的是SublimiteText2,我没有看到,我花了24个小时搜索互联网并修改代码,我甚至在它上面尝试了jquery函数来尝试在Js^^之前加载DOM“真的非常感谢你!我没有足够的声誉来投票支持你,但我会回来的承诺=)
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src= "popup.js"></script>
</head>
<body>
<p id="firstText">this is the text to be repeated</p>
<p id= "secondText"></p>
</body>
</html>