Convert long javascript element codes into smaller ones
<p>I have been looking for this (and trying by myself) but so far couldn't make it work.</p>

<p>I have the following  that onClick it triggers a toggle function:</p>

<pre><code>function toogle(){
    document.getElementById('id1').style.top = (document.getElementById('id1').style.top != '-130px' ? '-130px' : '0px')}
</code></pre>

<p>It works as I wanted but I would also like to make it a bit short, I tried doing </p>

<pre><code>var smalltag = document.getElementById('id1').style.top;
smalltag  = (smalltag  != '-130px' ? '-130px' : '0px')

or

var smalltag = "document.getElementById('id1').style.top";
smalltag  = (smalltag  != '-130px' ? '-130px' : '0px')
</code></pre>

<p>but none worked, how can I make it work? Also would like a brief explanation so I can understand it better (if possible).</p>

<p>Forgot to say, I do not intent to use any javascript packages, I am trying to learn the javascript as best as I can and using such packages would be a bad way to do so (meaning no jquery, mootools, etc).</p>

<p>Thank you for yout attention!</p>
