detach method (NodeIterator)
9 | 3.5 | |||
Releases the current NodeIterator object and puts the iterator into the invalid state.
Note: The NodeIterator object and its detach method are supported in Internet Explorer from version 9.
A call to the nextNode or the previousNode methods raises an exception after the detach method has been invoked.Syntax:
You can find the related objects in the Supported by objects section below.
Return value:
This method has no return value.
Example HTML code 1:
This example illustrates the use of the the detach method:
|
||||
<head> <script type="text/javascript"> function ElementChecker (node) { if (node.tagName.toLowerCase () == 'button') { return NodeFilter.FILTER_ACCEPT; } return NodeFilter.FILTER_SKIP; } function FindFirstButton () { // try..catch is necessary because the createNodeIterator method is supported but not implemented in Firefox before version 3.5. try { iterator = document.createNodeIterator (document, NodeFilter.SHOW_ELEMENT, ElementChecker, false); var button = iterator.nextNode (); alert ("The label of the first button element : " + button.textContent); iterator.detach (); } catch (e) { alert ("Your browser does not support the createNodeIterator method!"); } } </script> </head> <body> <button onclick="FindFirstButton ()">Find the first button tag with the NodeIterator object</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments