+ 5

className is not a function

I don't understand why doesn't work. somebody can help me? JavaScript Console TypeError: unhide.className is not a function Line: 28 <!DOCTYPE html> <html> <head> <title>Page Title</title> <style type="text/css"> .hidden { display: none; } .visible { display: inline; } </style> <script> function muestra() { var unhide = document.getElementById("text01"); unhide.className("visible") } </script> </head> <body> <p id="text01" class="hidden"> Phasellus magna sem, semper quis, faucibus ut, rhoncus non, mi. Duis pellentesqu</p> <a id="enlace" href="#" onclick="muestra(); return false;">unhide</a> </body> </html>

28th Jul 2017, 11:37 PM
Gonzalo
Gonzalo - avatar
12 odpowiedzi
+ 15
That's because className is not a function. :D className is a Javascript property, so... the correct syntax is: element.className = "class";
28th Jul 2017, 11:43 PM
Maz
Maz - avatar
+ 10
@Gonzola I am the biggest idiot that is in the top 50. Maybe because I am the youngest
28th Jul 2017, 11:56 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 10
14 years and 2 months (exactly) old
28th Jul 2017, 11:58 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 9
Class is an ENCAPSULATION of functions.
28th Jul 2017, 11:47 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 6
Ohhh...☺ I'm older than you by 2.286 times😂(not exactly)
29th Jul 2017, 12:01 AM
Вап
+ 5
$Vengat how old are you?
28th Jul 2017, 11:58 PM
Вап
+ 4
@Gonzalo Not only you😁
28th Jul 2017, 11:51 PM
Вап
+ 3
Oh my god. I'm a idiot. thanks!
28th Jul 2017, 11:46 PM
Gonzalo
Gonzalo - avatar
+ 3
@Denis Thanks!☺
29th Jul 2017, 4:44 PM
Вап
+ 2
congrats! @4rontender on becoming Platinum
29th Jul 2017, 4:24 PM
CMD
CMD - avatar
+ 2
thanks
29th Jul 2017, 5:00 PM
punith gowda
punith gowda - avatar
+ 1
thanks
3rd Aug 2017, 11:30 AM
punith gowda
punith gowda - avatar