0

Problem with Javascript function

Hi . I made a function in Javascript but i always get a bug . Can you say the problem with my function? Here's the function: function general() { a.style.border = 2px solid red ; a.style.color = "green" ; }

29th Jul 2025, 9:45 AM
Seyyed Abbas Hosseini
Seyyed Abbas Hosseini - avatar
4 Réponses
+ 3
Is variable 'a' declared? U might want to find it using a selector query. Also i am pretty sure the 2px solid red line should be in quotes.
29th Jul 2025, 9:48 AM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
0
Yes the variable is declared. Yeah sorry i forgot quotes . But anyways i still see a bug
29th Jul 2025, 11:33 AM
Seyyed Abbas Hosseini
Seyyed Abbas Hosseini - avatar
0
Seyyed Abbas Hosseini can u provide more info then? Like an error message or full code?
29th Jul 2025, 11:53 AM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
0
Lemme send you the error message: Uncaught TypeError : Cannot read properties of null ( reading 'style' )
29th Jul 2025, 11:58 AM
Seyyed Abbas Hosseini
Seyyed Abbas Hosseini - avatar