Instead of:
var bodytext = $('#thirdspan').text;
You should do:
var bodytext = $('#thirdspan').text();
because .text
is a method, so it needs the ()
to call it
Cheers
Question
So I have this span, that has a content editable attribute on it and when you hit the button post -- I want to get the value of that span, but it doesn't seem to be working.
Note: I really cannot change the span to a textbox or to a div or anything -- I just really need the value from that content editable span.
Here is the HTML:
<span id="thirdspan" contenteditable="true">Write context text here:</span>
Here is the CSS:
color: black;
font-family:'Roboto';
outline: 0px solid transparent;
Here is the JS:
var bodytext = $('#thirdspan').text;
alert(bodytext);
Thanks so much to anyone who can help!
La solution 2
Instead of:
var bodytext = $('#thirdspan').text;
You should do:
var bodytext = $('#thirdspan').text();
because .text
is a method, so it needs the ()
to call it
Cheers
Autres conseils
You'll want $('#thirdspan').text();
. Or $('#thirdspan').html();
, since contenteditable allows editing html.
Should be:
var bodytext = $('#thirdspan').text();
Be sure you have jquery loaded