0 votes
by (470 points)

Hello guys. Trying to replace style inside passage. Of course i set $images in StoryInit

passage contains this

<div id="start" style="margin-left: 200px;"

and i have a link to change it

<<link 'IMAGE ON/OFF'>>
	<<if $images is false>>
		<<set $images to true>>
		<<set document.getElementById("start").style.margin-left="220px">>
		<<refresh>>
	<<elseif $images is true>>
		<<set $images to false>>
		<<set document.getElementById("start").style.margin-left="0px">>
		<<refresh>>
	<</if>>
<</link>>

As a result i have this

Error: <<set>>: bad evaluation: Invalid left-hand side in assignment.

But $images changing normally. I took an example from this answers, but it doesnt work. Please help

1 Answer

0 votes
by (68.6k points)

The properties of an element's style API are (mostly) in camelCase, not kebab-case.  Thus, you want marginLeft, rather than margin-left.

Alternatively, use jQuery.  For example:

<<run $("#start").css("margin-left", "220px")>>

 

by (470 points)
edited by
<<set document.getElementById("start").style.marginLeft="220px">>

doesnt work too: 

Error: <<set>>: bad evaluation: Cannot read propery 'style' of null.

jquery does not give an error, but the value does not change .-.

...