netpumber Posted February 25, 2013 Share Posted February 25, 2013 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. Link to comment https://forums.phpfreaks.com/topic/274934-writing-a-text-editor-unbold-the-bold-text/ 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. Link to comment https://forums.phpfreaks.com/topic/274934-writing-a-text-editor-unbold-the-bold-text/#findComment-1414888 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. Link to comment https://forums.phpfreaks.com/topic/274934-writing-a-text-editor-unbold-the-bold-text/#findComment-1414911 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. Link to comment https://forums.phpfreaks.com/topic/274934-writing-a-text-editor-unbold-the-bold-text/#findComment-1414913 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? Link to comment https://forums.phpfreaks.com/topic/274934-writing-a-text-editor-unbold-the-bold-text/#findComment-1414922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.