javascript - How to get the previous text node that is displayed before a given one? -
i´m trying implement own caret , when it´s @ start of text , go left should go previous text node in dom. problem not previous sibling find easiely. in @ bottom of tree of sibling of parent. should clarify problem:
function getprevioustextelement(node) { var prev = $('.caret').closest(':text'); prev.css('color', 'green'); }
#carot{ color:red; }
<div> 1 <div> 2 <div>3</div> <div>4</div> <div>5 <div>6</div> <div> 7 <div>8</div> <div>9</div> </div> </div> </div> </div> <div> <span id="carot">|</span>10 </div>
so when caret @ "10" , press left should go "9" how element? there js or jquery functions i´m missing? jquery closest(), prevall() or parents() doesn´t seem job.
it can done assigning custom data or class of item , jquery selector $(".customclass"), wich return possible elements, currentindex -1 item.
it's bit tricky solution job.
Comments
Post a Comment