JQuery cannot capture html contenteditable val

I have a div with contenteditable="true"that im uses instead textarea
using jQuery, I can't write it val()
heres my fiddle
thanks

+5
source share
4 answers

If it is equal div, you must capture .text().

Fiddle: http://jsfiddle.net/jPD7y/4/

+7
source

Some general tips, even if you get an answer

.val () = getting value from elements such as text, text field, selection, checkbox

.text () = getting text values ​​( excludes html tags ) from elements such as text, text field, selection, checkbox

.html() = html , span, div p table..etc..

<input type="text" id="someid" value="1234" />
$('#someid').val(); //1234
<p>bla bla bla<span>hello</span></p>
$('p').text(); //bla bla bla
$('p').html(); //bla bla bla<span>hello</span>
+11

textarea, div val().

+1

Change the line with ...

var mypost = $('#myTextArea').val();

to

var mypost = $('#myTextArea').text();
0
source

All Articles