Learn Prototype
Prototype Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
Prototype from() Method
This method clones an existing array or creates a new one from an array-like collection.
This is an alias for the $A() method.
Syntax:
Return Value:
- Returns an array having all the elements from the passed selector.
Example:
<html>
<head>
<title>Prototype examples</title>
<script type="text/javascript"
src="/javascript/prototype.js">
</script>
<script>
function showOptions(){
var NodeList = $('employees').getElementsByTagName('option');
var nodes = Array.from(NodeList);
nodes.each(function(node){
alert(node.nodeName + ': ' + node.innerHTML);
});
}
</script>
</head>
<body>
<select id="employees" size="10" >
<option value="5">Mohtashim, Mohd</option>
<option value="8">Debi, Patnaik</option>
<option value="1">Madisetti, Praveen</option>
</select>
<br />
<input type="button" value="Show the options"
onclick="showOptions();"/>
</body>
</html>
|
To understand it in better way you can Try it yourself.
|
|
|