#137 enhancement
P. Douglas Reeder

Placement Examples for Element.insert()

Reported by P. Douglas Reeder | May 14th, 2009 @ 07:36 PM

I wrote some additional examples to clarify how the placement parameters top, bottom, before and after work.

<html>
<head>
<title>Prototype examples</title>

<script type="text/javascript" 
   src="/javascript/prototype.js">
</script>
<script>

function showResult(){
   var elem = $('apple').insert( "<li>mangoes</li>" );
   alert(elem.innerHTML );
}

function showPlacement() {
    var str = $('orange').insert({top:"foo-", before:"<li>pears</li>"});
    alert(elem.innerHTML);
}
</script>
</head>

<body>

  <p>Click the button to see the result.</p>

  <ul>
   <li id="apple">apple</li>
   <li id="orange">orange</li>
  </ul>

  <br />
  <input type="button" value="append" onclick="showResult();"/>
  <input type="button" value="top + before" onclick="showPlacement();"/>

</body>
</html>

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Shared Ticket Bins

Pages