Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript insertAfter

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #185003
    deeve007
    Participant

    If you use insertBefore to move a DIV in your markup, is it then possible to have it return to its original position without specifying the position using the same method?

    Cheers.

    #185005
    __
    Participant

    Not AFAIK. You’d need to “remember” where it used to belong (assign the former previousSibling to a variable).

    #185009
    deeve007
    Participant

    No previous sibling, but how do you assign the previous element to a variable? Can’t find the correct way/code from googling…

    #185010
    __
    Participant

    read about previousSibling / nextSibling.

    If it has neither (i.e., is an only child), you can use the parentElement.

    #185013
    deeve007
    Participant

    No parent DIV. Well, BODY would be the parent DIV, but if your idea is going to work I need to identify the previous element before the one I’m moving.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.