Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

swapNode method

Exchanges the location of two objects in the document hierarchy.

Syntax

object.swapNode(otherNode)

Parameters

otherNode [in]

Type: IHTMLDOMNode

Object that specifies the existing element.

Return value

Type: IHTMLDOMNode

Returns a reference to the object that invoked the method.

Standards information

There are no standards that apply here.

Remarks

This method is accessible at run time. If elements are removed at run time, before the closing tag is parsed, areas of the document might not render.

Examples

This example uses the swapNode method to exchange the location of two objects.


<!DOCTYPE html>

<html>
<head>
  <title>swapNode</title>
</head>
<body>
  <ul id="oList">
    <li>List Item 1</li>
    <li>List Item 2</li>
    <li>List Item 3</li>
    <li>List Item 4</li>
  </ul>
  <input type="button" value="Swap List" onclick="fnSwap()">
  <script>
    function fnSwap() {
      var oList = document.getElementById('oList');

      oList.children[0].swapNode(oList.children[1]);
    }
  </script>
</body>
</html>

See also

a
abbr
acronym
address
applet
area
article
aside
attribute
b
base
baseFont
bdo
bgSound
big
blockQuote
body
br
button
caption
center
cite
code
col
colGroup
comment
dd
del
dfn
dir
div
dl
documentType
dt
em
embed
fieldSet
figcaption
figure
font
footer
form
frame
frameSet
head
header
hgroup
hn
hr
html
i
iframe
img
input type=button
input type=checkbox
input type=email
input type=file
input type=hidden
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
ins
kbd
label
legend
li
link
listing
map
mark
marquee
menu
nav
nextID
object
ol
option
p
plainText
pre
ProcessingInstruction
q
s
samp
script
section
select
small
span
strike
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
title
tr
tt
u
ul
var
xmp
Reference
cloneNode
removeNode
replaceNode
Conceptual
About the W3C Document Object Model

 

 

Show:
© 2014 Microsoft