I need to make a div layer so that when you click on it you will have your cursor there blinking and you can insert/delete text just like <input type="text">
does, except that I do not want to use it as it is slightly too limited to my case.
I can definitely use JavaScript.
as I understand your problem, you can resove it by adding
textarea
into yourdiv
. It is very simply to make thistextarea
autosize to occupy wholediv
area and looks like thisdiv
.As for
contentEditable
, I have seen some browsers, supported this feature fordiv
-element and does not. Anyway, you can useiframe
in your div. It'sdocument
-element can havecontentEditable
.Jquery can be used like this:
You can make the div editable by setting its
contentEditable
attribute / property totrue
. However, for anything that is slightly more powerful or flexible then very basic editing, you might want to look at existing solutions such as:contenteditable attribute could be used for this purpose. Following code line has been tested in IE7 and Firefox 3.0.10. One part, I have noticed that this attribute should be used in lower case only; else it wont work in Firefox.
DIV element has (other elements as well)
contentEditable
property that you can set in Javascript to true.I suggest you to use a textarea, and if that's not enough, use a WYSIWYG editor like tinyMCE or FCKeditor.