首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >JQuery无法在Chrome扩展内容脚本上执行

JQuery无法在Chrome扩展内容脚本上执行
EN

Stack Overflow用户
提问于 2018-04-30 12:16:15
回答 1查看 133关注 0票数 0

在这里,我有最简单的chrome扩展。我注意到JQuery似乎没有在我的内容脚本中执行。然而,普通的javascript运行得很好。我想知道是什么阻止了JQuery的执行。

清单

代码语言:javascript
复制
{
    "manifest_version": 2,
    "name": "test",
    "version": "1.0",
    "description": "test",
    "background": {
    "scripts": ["popup.js"]
    },
    "content_scripts": [{
        "matches": ["http://*/*", "https://*/*"],
        "js": ["jquery.js", "content.js"]
    }]
}

popup.js

代码语言:javascript
复制
chrome.runtime.onMessage.addListener(function (response, sender, 
    sendResponse)
{
    alert("test");
    alert(response.test.toString());
});

内容脚本

代码语言:javascript
复制
chrome.runtime.sendMessage({test: 
    $(".chapters").first().innerHTML.toString()}, function(response){});

//document.getElementsByClassName("chapters")[0].innerHTML.toString()} works 
just fine
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-30 05:33:03

jQuery没有innerHTML属性。使用.html()就是答案。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50093885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档