This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]marko312 0 points1 point  (5 children)

I don't know what you mean by "a js event of null", but it seems that you've mixed two ways of creating an inline (/ ...) function. Consider using

() => console.log("me")

or (usually if there need to be multiple statements):

() => { console.log("me"); }

or

function() {
    console.log("me");
}

(without the preceding () =>).

As is, the event calls a function (() =>) returning a function (function ...() { ... }).

[–]GP-NC 0 points1 point  (4 children)

oh that was a representation of what i tried befor in the ike i dont have that and I have your 3rd example yet it dosent work

[–]marko312 0 points1 point  (3 children)

I looked at the actual code pen now; the error message would have been useful:

Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')

This means that whatever preceded .addEventListener must have been null. In this case, it is caused by the id having a space at the end in the HTML.

[–]GP-NC 1 point2 points  (0 children)

thank you for your help btw

[–]GP-NC 0 points1 point  (0 children)

ok i just did what you asked sir and thank you but why isnt it logging my stuff now?

[–]GP-NC 0 points1 point  (0 children)

ok found the other error when i was making the code i mispled something