When you create a SELECT node while using the DOM model, you want to delete the solution to the Option item.

zhaozj2021-02-16  37

In practical use, I met a shortcomings of JavaScript and a algorithm that I have exploded.

After a SELECT node is created, do not need to delete the secondary node at each time, but to update the content (options) of the node, you must delete the original Options, it is estimated that the language inventor's big best do it. Not good enough, not all delete, and it is necessary to use an algorithm when it is discovered by multiple tests. Only half of the Options length can only be removed each time. The implementation process is as follows:

VAR select = document.createElement ("SELECT");

Var OOPTION = New Array ();

FOR (var i = 0; i <10; i ) {

OOPTION [I] = Document.createElement ("Option");

SELECT.ADD (OOption [I]);

} // Generate a SELECT node

// Deleted algorithm

While (Length! = 0) {var longth = select.Options.LENGTH; for (var i = 0; i

转载请注明原文地址:https://www.9cbs.com/read-27615.html

New Post(0)