getelementbyID trouble

I have what may be a super simple problem but cannot break through it. I want to create a “menu” where, when clicking on an icon, a background element expands and the menu contents appear. I’ve had no trouble building the javascripts for the other things I’m doing on the site, but this one eludes me! Here is what I have. But when I click the icon nothing happens or changes. Anything obvious jump out to anyone?
var eleID = hypeDocument.getElementById(‘rightband’);
hypeDocument.setElementProperty(‘eleID’, ‘width’, 300, 1.0, ‘easeinout’);

I’m not doing this as a timing element or with a timeline because I want the user to be able to bring up this menu regardless of what else they have clicked on or done on the site. Any tips on where I might have gone wrong would be great appreciated!

Hypes API requires the element and not its id …

**hypeDocument.setElementProperty(element, propertyName, value, optionalDuration, optionalTimingFunctionName)**

isn’t the element what is returned by hypeDocument.getElementById ?

you passed string as argument ... not an element

So it should be (e.g. sans quotes) ?

var eleID = hypeDocument.getElementById('rightband');
hypeDocument.setElementProperty(eleID, 'width', 300, 1.0, 'easeinout');

exact :slight_smile:

I thought so but I tried that first and nothing happened.

well, in that case a simplified hypedoc may be useful :slight_smile:

sample.hype.zip (10.4 KB)

1 Like

Just jumping in here to say that when you post code here and don’t put it in a code block, it won’t work for others because of the smart quotes:

If you select your code and click the 28%20AM button it will convert this text (with smart quotes not parseable by JavaScript) to code that is.

@jkinsella – it actually looks like the code you were using did have smart quotes in it. Make sure that you are typing the ' key inside of Hype and not in rich text editor so you actually get an apostrophe and not a smart quote.

1 Like

Thank you to everyone for the help! It turns out, I was doing it right all along! So what was the problem? I was adjusting the width of an element at the far right of my scene. So when the width adjusted, if adjusted to the right, off the edge of the scene and from my point of view it didn’t appear to be changing at all.