Copyright © tutorialspoint.com

Prototype update() Method

previous next


Advertisements

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.

Syntax:

element.update( newContent );

Return Value:

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>

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


previous next

Copyright © tutorialspoint.com