Reputation: 541
I want to find out, when my text goes over the content editable div.
I dont want to have a scroll or anything, just as it is.
What I want is to block (not hiding with overflow, blocking!!) any text which goes below the div.
Here is my JSFiddle with my problem.
Thanks in advance.
Upvotes: 0
Views: 596
Reputation: 33
<html>
<head>
<style>
div.block{margin:20px;width:400px;height:100px;overflow:hidden;}
//defined some style just for demonstration
</style>
<body>
<div class="block" contenteditable="true" onkeyup="ManageOverflow(event)">
Block Content
</div>
</body>
<script>
function ManageOverflow(event){
if(event.target.scrollHeight > event.target.clientHeight){
//your action here
}
}
</script>
</html>
Upvotes: 2
Reputation: 9451
As other's are saying, you can use text-overflow: ellipsis
, but unfortunately, this will only work with one line (not multi lines)
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
If you want multi-lines, you won't get an ellipsis
overflow: hidden;
Upvotes: 0