• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Problem in using the inserBefore() method

Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am quite lost as to how to use the method insertBefore() in order to have a sentance inserted Before the text.
Note: Inserting a sentence before the orginal text before.

Can any one check this example out and correct the problem.
function addText()
var sentence = document.form1.sentence.value;
var node=document.createTextNode(sentence +"");
var p1= document.getElementById("p1");
p1.firstChild.insertBefore(node); // problem is here
ID="p1" Using W3C Dom, you can dynamically add sentances. Type a sentence and click the add Button</p>
Thanks to all-Glen
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic