troubleshooting Question

Element.getAttribute("onClick") returns empty String

Avatar of jespersahner
jespersahner asked on
JavaScript
9 Comments1 Solution2370 ViewsLast Modified:
Hi!

I am using Element.getAttribute() to find attributes in an input-tag like this:
<input type="checkbox" onClick="toggle('bla. bla.')">

getAttribute("type") returns "checkbox", but getAttribute("onClick") returns an empty String.

Formally this might not be a bug due to the DOM specification, but how is the "toggle('bla. bla.')" identified, if getAttribute("onClick") cannot be used?

Regards,
Jesper
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros