Skip to content
Advertisement

this.name returns undefined in javascript

I am trying to remotely create an onclick for each <div> (to save typing time).

Here is the window.onload() function:

JavaScript

The name of every <div> is "flyingsheep" – this value was set by <div name="flyingsheep">.

When I click the <div>, the iframe "game" takes me to the webpage "/games/undefined".

Advertisement

Answer

This will work. the problem is corrected.

just use : this.attributes["name"].value

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