Reputation: 4693
i have a div with contenteditable="true"
that im using in place of textarea
using jQuery, i cant seem to capture its val()
heres my fiddle
thanks
Upvotes: 6
Views: 7837
Reputation: 232
Change the line from....
var mypost = $('#myTextArea').val();
to
var mypost = $('#myTextArea').text();
Upvotes: 0
Reputation: 7954
Some general tips even if you got the answer
.val() = getting value from elements like text,textarea,select,checkbox
.text() = getting text values(excludes html tags) from elements like text,textarea,select,checkbox
.html() = getting html content from elements like span,div p table..etc..
Examples
<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>
Upvotes: 12
Reputation: 268344
With it being a div
, you would grab the .text()
.
Fiddle: http://jsfiddle.net/jPD7y/4/
Upvotes: 9