netpumber Posted February 25, 2013 Share Posted February 25, 2013 (edited) Hello im trying to make a text editor for a site and i have some problems with javascript. I started here as simple as can be, without any textarea and so. At first im just trying to modify a <p>. Here you can see the code. http://jsfiddle.net/9e753/ As you can try i can make the text bold but i cannot undo it. Also i want to ask you haw can i achieve to make this change: (lets say we have a bolded text) text and we want to unbold only two or one letter eg: text text and so on... Any hint is welcomed. Thanks in advance. Edited February 25, 2013 by netpumber Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 25, 2013 Share Posted February 25, 2013 You'd have to insert spans around the letters you want to change. You should consider using an existing tool like TinyMCE. No need to reinvent the wheel when it's a really complicated wheel and every road has different rules. Quote Link to comment Share on other sites More sharing options...
netpumber Posted February 25, 2013 Author Share Posted February 25, 2013 Thanks for your answer. Ok lets say i add spans. How i remove them with javascript ? I will try the TinyMCE also , but i wanna find the way that these editors works. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 25, 2013 Share Posted February 25, 2013 The same way you add them, but in reverse. I'd do it in jQuery if I were doing it. Quote Link to comment Share on other sites More sharing options...
netpumber Posted February 25, 2013 Author Share Posted February 25, 2013 But im adding them with surroundContents() and there is no removeSouroundContents() function . What you mean with the same way? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.