javascript - if div height is greater than 100 move exceed text to another div -
i have 2 contenteditable div, want if div (div a) height become greater 100px move exceed text div (div b).
i
am
learning
(for example, here div height greater 100px, move "javascript" div)
javascirpt.
and next time if more text added div , move text base on height again.
testing again
i
am
(for example, here div height greater 100px, move "learning javascript" div)
learning
javascirpt.
jsfiddle link http://jsfiddle.net/mhabib555/zvq96xy6/2/
function checkheight(){ var diva = document.getelementbyid('a'); var divb = document.getelementbyid('b'); var status = document.getelementbyid('status'); status.innerhtml = diva.clientheight; if(diva.clientheight>100) { //move exceeded text div b } }
<div contenteditable='true' id='a' onkeyup='checkheight()'>edit me</div> <div contenteditable='true' id='b'>edit me 2</div> <div>current height : <span id='status'></span></div>
maybe setting focus on div b when height exceeds div a.
if(diva.clientheight > 100) { document.getelementbyid('b').focus; // more code` }
Comments
Post a Comment