display Text under text using javascript & DHTML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nskclr
    New Member
    • Aug 2007
    • 2

    display Text under text using javascript & DHTML

    Hi

    I add a text using document.select ion.createRange ().
    I want to add a text to the bottom of another text - similar to what we do in HTML.
    <p>
    xyz
    </p>
    <p><div style="position :relative;botto m:30px;">abc</div></p>

    How can I achieve that using javascript?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN!

    You may want to read about the insertBefore method. There's no insertAfter method, but the page explains how that can be achieved.

    Comment

    • nskclr
      New Member
      • Aug 2007
      • 2

      #3
      I want to add the text to the text inside textarea. So I use document.select ion.createRange () and populate it using createRange().t ext. As there is no element associated with in the textarea, I am unable to use the insertBefore() method. Please give me some other option.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by nskclr
        I want to add the text to the text inside textarea. So I use document.select ion.createRange () and populate it using createRange().t ext. As there is no element associated with in the textarea, I am unable to use the insertBefore() method. Please give me some other option.
        In that case, just add it to the value of the textarea:
        [CODE=javascript]document.getEle mentById("texta reaID").value += whatever;[/CODE]

        Comment

        Working...