I would like to use the querySelector but it does not work. I think I need to put a word in the permissions but I can't find it. It's also possible that my code is bad I'm a beginner in js (If you have something to optimize my code I won't say no ;) ) I am making a calculator and I would like to know when I click on a number.
var debugmyextension = 7;
const one = document.querySelector(one);
one.addEventListener('click', event => {
var debugmyextension = 2;
});
const two = document.querySelector(two);
const three = document.querySelector(three);
const four = document.querySelector(four);
const five = document.querySelector(five);
const six = document.querySelector(six);
const seven = document.querySelector(seven);
const eight = document.querySelector(eight);
const nine = document.querySelector(nine);
const zero = document.querySelector(zero);
my manifest file :
{
"name": "multi-jeu",
"description": "de Jean Heubel",
"version": "1.0",
"manifest_version": 3,
"background": {
"service_worker": "/js/app.js"
},
"permissions": [
"background",
"storage",
"clipboardWrite",
"clipboardRead"
],
"action": {
"default_popup": "index.html",
"default_icon": {
"16": "/img/Capture d’écran 2021-09-07 122140.png"
}
},
"icons": {
"16": "/img/Capture d’écran 2021-09-07 122140.png"
}
}
my error message :
js/app.js:2 (fonction anonyme) :
const one = document.querySelector(one);
Well, we don't have your HTML, but let me explain querySelector, if you have a class in HTML and you want to use it in Javascript, then do document.querySelector('.class-name') "class-name is for example the name of your class", for an id, you would do document.querySelector('#id-name'),for a whole element you would do document.querySelector('body') "body is the element that you want to import" you can see it as you style elements in css.
here is some documentationthat can be helpful