chrome扩展程序popup.js无法正常工作 [英] chrome extension popup.js is not working
本文介绍了chrome扩展程序popup.js无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个看起来像这样的popup.html
I have a popup.html that looks like this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link type="text/css" rel="stylesheet" href="css/fbh-ui.css" />
<script type="text/javascript" src="js/jq.js"></script>
<script type="text/javascript" src="js/fbh-popup.js"></script>
</head>
<body style="width: 200px">
<div id="fbh-main">
<div id="fbh-popup-enabled"></div>
</div>
</body>
fbh-popup.js看起来像这样
And fbh-popup.js looks like this
$('#fbh-popup-enabled').html('test');
JS应该更改div的内容,但不能更改.我什至在JS文件中尝试了一个简单的console.log('test'),但是没有触发.我很茫然.
The JS should alter the content of the div but does not. I even tried a simple console.log('test') in the JS file and that didn't fire. I am at a loss.
推荐答案
您必须在 ready事件中编写代码回调
$(document).ready(function() {
$('#fbh-popup-enabled').html('test');
});
这篇关于chrome扩展程序popup.js无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文