- Prototype - Home
- Prototype - Short Overview
- Prototype - Useful Features
- Prototype - Utility Methods
- Prototype - Element Object
- Prototype - Number Processing
- Prototype - Strings Processing
- Prototype - Array Processing
- Prototype - Hash processing
- Prototype - Basic Object
- Prototype - Templating
- Prototype - Enumerating
- Prototype - Event Handling
- Prototype - Form Management
- Prototype - JSON Support
- Prototype - AJAX Support
- Prototype - Expressing Ranges
- Prototype - Periodical Execution
Prototype - update() Method
This method replaces the content of the element with the provided newContent argument and returns the element.
Given newContent can be a plain text, an HTML snippet, or any JavaScript object, which has a toString() method. If it contains any <script> tags, these will be evaluated after element has been updated.
If no argument is provided, Element.update will simply clear element of its content.
Syntax
element.update( newContent );
Return Value
Updated HTML element.
Example
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
$('movies').update("Spider Man, USV-315");
}
</script>
</head>
<body>
<p>Click the button to see the result</p>
<div id = "movies">
Speed, Titanic, Brave Heart
</div>
<input type = "button" value = "Click" onclick = "showResult();"/>
</body>
</html>
Output
prototype_element_object.htm
Advertisements