JavaScript Reference/Javascript Methods/addElement

Материал из Web эксперт
Перейти к: навигация, поиск

"addElement()" Example

    
<html>
<head>
<script language="JavaScript">
function function1() {
    myRange = document.body.createControlRange();
    myDiv = document.createElement("div");
    document.body.insertBefore(myDiv);
    myDiv.style.position = "absolute";
    myDiv.innerText = "Here is the new content.";
    myRange.addElement(myDiv); 
} 
</script>
</head>
<body>
<input id=myB 
       type="button" 
       value="Add element to the controlRange collection" 
       onclick="function1();">
</body>
</html>



"addElement()" is applied to

Names noted with an asterisk (*) are JavaScript properties only.
+----------------+--------------------------------------------------------------+
| Applied_To     |controlRange*                                                 |
+----------------+--------------------------------------------------------------+



"addElement()" Syntax, Parameters and Note

Note:
Adds an element to the controlRange collection.
    
Syntax:
    
controlRangeName.addElement(param1)

Parameters:
    param1   Required; the element to add.