A new JavaScript tutorial(Beta)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robi

    #16
    Re: A new JavaScript tutorial(Beta)

    binnyva wrote in message news:1125684704 .981079.288230@ z14g2000cwz.goo glegroups.com.. .[color=blue]
    > Hi,
    >[color=green]
    > > Writing a short tutorial (or even an in depth one) could
    > > be considered a good exercise to expand one's understanding
    > > of a topic. I wouldn't say this is a complete waste of time.[/color]
    > Yes, writing the tutorial increased my knowledge. But
    > it is not by the contents of the tutorial - but by the
    > research I put into making it.[/color]

    On the "Moving Stuff around" page, I would add the possibility
    of interchanging the <DIV>s in the other parental <TD>s

    i.e.:
    document.getEle mentById("joke_ 1").parentNode. nextSibling.app endChild(docume nt.getElementBy Id("joke_1"));
    document.getEle mentById("joke_ 2").parentNode. previousSibling .appendChild(do cument.getEleme ntById("joke_2" ));

    document.getEle mentById("joke_ 1").parentNode. insertBefore(do cument.getEleme ntById("joke_1" ),document.getE lementById("jok e_1").parent
    Node.firstChild );
    document.getEle mentById("joke_ 2").parentNode. insertBefore(do cument.getEleme ntById("joke_2" ),document.getE lementById("jok e_2").parent
    Node.firstChild );

    The first group switches the <DIV>s

    <table>
    <tr>
    <td><div id="joke_1">... </div></td>
    <td><div id="joke_2">... </div></td>
    </tr>
    </table>
    into
    <table>
    <tr>
    <td><div id="joke_2">... </div></td>
    <td><div id="joke_1">... </div></td>
    </tr>
    </table>

    the second group just moves the <div> to the first position of each <td>

    switching effectively the jokes without positioning them ;-)

    I'm sure the movement could be made easier or just with two lines,
    but I didn't take the time to do that.

    another possibility to move them, is to assign
    document.getEle mentById("joke_ 1").offsetLe ft to a variable and
    document.getEle mentById("joke_ 2").offsetLe ft to another and then
    assign the variables +"px" to
    document.getEle mentById("joke_ 2").style.le ft and
    document.getEle mentById("joke_ 1").style.le ft

    that's what I was missing in my previous post in this thread.
    But that only positions the DIVs; although in "wrong" containers.
    The appendChild/insertBefore version places them into the "correct"
    containers, right in the container's position.

    Richard, thanks for the style lecture, that got me on the track ;-)

    Robi

    Comment

    Working...