1

Right now i am trying to do a Guide for developing Chrome Extensions. I'm relatively new to programming. The extension should Update the popup with a new Value. Do someone knows what am i doing wrong here?

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());
    })
})

This error appears

  • 1
    `popup.js` depends on jQuery to be available. Move the `script` tag below the jQuery one. – msg Oct 27 '20 at 20:28

0 Answers0