Copyright ©

Prototype update() Method

previous next


This method replaces the content of element with the provided newContent argument and returns element.

Given newContent can be 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.


element.update( newContent );

Return Value:


<title>Prototype examples</title>

<script type="text/javascript" 

function showResult()
   $('movies').update("Spider Man, USV-315");



  <p>Click the button to see the result</p>
  <div id="movies">
      Speed, Titanic, Brave Heart

  <input type="button" value="Click" onclick="showResult();"/>


To understand it in better way you can Try it yourself.

previous next

Copyright ©