how? Javascript HTML code question?

For developers using the Construct 2 Javascript SDK

Post » Fri Mar 13, 2015 9:44 am

I am trying to access the "Style" part of an object in my index.html file using a function and was wondering if anyone knew how to do this? I am having some success but I think its a matter of scope.

In one function I have loaded and set the style of an image and assigned it to a var logo.
Then added and appended to the className

logo.className += " logo-branding-image";
document.body.appendChild(logo);


In another function I have some code that should change its visibility:
document.getElementsByName('logo').style.visibility = 'visible';

From construct I am calling this function to change the visibility, but logo (or whatever I use in its place) is undefined.

Would anyone know how to correct this issue so I can make that happen?
Some games: https://play.google.com/store/search?q= ... s&hl=en_GB Feel free to show the panda some support, he would appreciate it :)
B
19
S
5
G
1
Posts: 155
Reputation: 1,619

Post » Fri Mar 13, 2015 11:02 am

This isn't really the right forum to ask general Javascript questions. You might want to ask on a site like StackOverflow.com.
Scirra Founder
B
367
S
217
G
82
Posts: 23,264
Reputation: 183,858

Post » Fri Mar 13, 2015 11:03 am

Thanks, no problem :)
Some games: https://play.google.com/store/search?q= ... s&hl=en_GB Feel free to show the panda some support, he would appreciate it :)
B
19
S
5
G
1
Posts: 155
Reputation: 1,619


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests