Discussion Locked

HTML editor in Javascript

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm making a basic HTML editor in Javascript... or atleast trying to. I can't figure out the function that will do this:

1. They click in the textarea where they would like to insert the "

" tag.
2. They click the "New Paragraph" button
3. The function inserts the "

" tag in that spot.

I've gotten it to append to the end, but I can't get it exactly where I want it. Is there any way to split the value of the textarea based on where the cursor is?

Any help would be appreciated. Thanks.

Brendan

1 reply

by jay eckles

My suggestion would be to have the user select a block of text and then click "new paragraph". This has two advantages: 1. you can use the selected property of the textarea to determine where to put the tags; 2. you force the user to include opening and closing paragraph tags, resulting in better markup.

Good luck.

Jay
www.jayeckles.com

This discussion is closed to new replies.