目前,我正在尝试编写Chrome扩展程序开发指南。我是编程新手。扩展名应使用新值更新弹出窗口。有人知道我在这里做错了吗?
popup.html
<!DOCTYPE html>
<html>
<head>
<title>Budget Manager</title>
<script src="popup.js">
</script>
<script src="jquery-3.5.1.min.js">
</script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Budget Manager</h1>
<h2>Total Spent: <span id="total">0</span> </h2>
<h2>Limit: <span id="limit"></span></h2>
<h3>Enter Amount</h3>
<input type="text" id="amount">
<input type="submit" id="spendAmount" value="Spend">
</body>
</html>
popup.js
$(function(){
$('#spendAmount').click(function(){
chrome.storage.sync.get('total', function(budget){
var newTotal =0;
if(budget.total){
newTotal += parseInt(budget.total);
}
var amaont = $('#amount').val();
if(amount){
newTotal += parseInt(amount);
}
chrome.storage.sync.set({'total': newTotal});
$('#total').text(newTotal);
$('#amount').val('');
})
$('#greet').text('Hello ' + $('#name').val());
})
})