Append before parent after getSelection()
        Posted  
        
            by sanceray3
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by sanceray3
        
        
        
        Published on 2010-03-08T17:30:05Z
        Indexed on 
            2010/03/08
            17:36 UTC
        
        
        Read the original article
        Hit count: 181
        
JavaScript
Hi all,
I have one question. I try to develop a little WYSIWYG editor.
I would like create a <h1> button which allows me to generate a <h1> title (by clicking on button after text selection in <p> element).
I obtain the selection with window.getSelection().... But now, I would like to put my append("<h1>my text selected</h1>") just before the <p>. It’s my problem, because my <p> elements don’t have id or class. So do you know a means to put my append just before the <p> where my text has been selected?
I don’t know if with my bad English you’ll understand me!
Thanks very much for your help.
© Stack Overflow or respective owner