Skip to content
Advertisement

Body OnClick doesn’t work… but the onclick works when attached to a tag?

I have the following Onclick event:

JavaScript

and when I attach it to:

JavaScript

all works fine, but I want it as a body onclick event as follows:

JavaScript

and I get no dice.

The only thing to note would be that the class “g” already has a background image specified, but I don’t think that should matter.

Advertisement

Answer

Use this. like this

JavaScript

JSFiddle of the code above jsfiddle.net/mrRRG/2/. But please do not use this type of code construction. It’s better to make few CSS classes and use javascript to change them on event fire

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement