Is it possible to make a <div> writable by the user?

you need to create a system that, when the user writes in the field a word starting with C #, is wrapped inside the html element. Inside input-text and textarea html do not work. I was thinking with a div, maybe?

+7
javascript html
source share
4 answers

Try the following:

<div contenteditable="true">Hello, edit me!</div> 

Not tested in Opera, works in Firefox 3, Google Chrome, Safari and Internet Explorer 6, 7 and 8.

+12
source share

Not sure what exactly you are looking for, but you can make divs as follows:

<div contentEditable="true"></div>

+6
source share

Not sure why the input or text box will not work; You can consider processing events triggered when a user enters data in a text box or input to achieve their goal. Or you can take a look at the wysiwyg editor.

+1
source share

Yes it is possible.

:)

Seriously, you need to parse the user input, and when your parser sees the “#” character, it just waits for the next [space] (for example, as a separator for the element identifier), create a new DOM element with that identifier and after that it should update innerHTML of this item every time the user enters a character.

0
source share

All Articles