I want to set the maximum text-length of the div.
I have this HTML code here:
<div contentEditable=true data-ph="Subject of this message" maxlength = "10" id = "discussionsubject">
</div>
In which I made the DIV
to act like textarea
. Now, I tried to set it's maxlength
by 10
but it doesn't worked.
Also tried this few codes found in other SO questions which seems not working fine with me:
var myDiv = $('#discussionsubject');
myDiv.text(myDiv.text().substring(0,10));
Also tried this code but still doesn't work:
$("div#discussionsubject).text(function(index, currentText) {
return currentText.substr(0, 10);
});
Please, need help..