Sorry if this question is very basic, but I'm trying to get back into programming and I'm stuck with this.
I want to have text input into a <div>
in HTML, but I don't want the default chat box that comes with <input>
. I just want it to directly print to a location within the <div>
.
How can I do this?
@Arkius have you tried using TextArea "http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea"
Use a
<div>
Make the div itself a text input (as you mentioned in the comments) by using
contenteditable
attribute:JSFiddle
To get the value you can use jQuery
$("div").text()
or jstextContent
To use the
<div>
inside a<form>
add some js to wire it up. You can see an example here.Use a
<textarea>
You can also use a
<textarea>
if you hide some properties:JSFiddle
To get the value you can use jQuery
$("textarea").val()
or jsvalue
You can use contenteditable attribute if you don't wanna submit its value to the server, just like this :
So that user can edit the text but it's not gonna be sent to the server and it's just a client side stuff.
But if you need to submit the value to the server you have to use TextArea or Input tag and remove the borders by CSS styles. Say :