I am Getting this error on Event Listener an Idea? Uncaught TypeError: console.log is not a function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I am Getting this error on Event Listener an Idea? Uncaught TypeError: console.log is not a function

/* Events Listener*/ document.addEventListener('click', (e) => { // Retrieve id from clicked element let elementId = e.target.id; var buttonName = elementId + ""; var removeChar = buttonName.replace(/[A-Za-z]/g, ""); //1_1_0 if (elementId !== '' && buttonName.match(/GridView/)) { const TablePrefix = "GridView"; if (buttonName.length == 19) { var buttonId = removeChar[0]; HideButtonsTicket(TablePrefix, buttonId); /* HideButtonsTicket(TablePrefix, buttonId);*/ } else if (buttonName.length == 21) { var buttonId = removeChar.slice(0, 2); HideButtonsTicket(TablePrefix, buttonId); } else if (buttonName.length == 23) { var buttonId = removeChar.slice(0, 3); HideButtonsTicket(TablePrefix, buttonId); } } else { console.log("An element without an id was clicked"); } } );

11th Aug 2022, 8:35 PM
Akang Toshi
Akang Toshi - avatar
4 Answers
+ 1
where it says if(elementld !== “… you have a { but not an } and i dont think u can put an else if inside an if. also !== isnt right it should be != with only 1.
11th Aug 2022, 8:41 PM
Junior
Junior - avatar
+ 1
ur welcome
11th Aug 2022, 9:18 PM
Junior
Junior - avatar
0
Yes thanks for the correction. I have removed the extra = but, same problem persist. And i think we can do nested else if inside an if.
11th Aug 2022, 8:54 PM
Akang Toshi
Akang Toshi - avatar
0
Okay i got it. There was another line above where i made a mistake. I wrote console.log="connected"; Getting mixed up with different languages😂 thanks anyway Your Mom
11th Aug 2022, 9:17 PM
Akang Toshi
Akang Toshi - avatar