0
I am making an input text using contenteditable, what I need is a Javascript button that when you click Focus in this field, I even managed, but after that I need to put the cursor at the end of the content, for the user to continue editing, so that the operation is equal to an input, motto that within this div may also have Ivs and spans, see what I already have:
$(document).on('click', '.btn', function (e) {
$('.formfield').focus();
});
.formfield{
width: 200px;
height: 30px;
display: block;
margin-bottom: 15px;
border: solid 1px #000000;
resize: none;
}
.btn{
width: 80px;
height: 30px;
line-height: 30px;
display: block;
margin-bottom: 15px;
background-color: #380303;
color: #ffffff;
text-align: center;
cursor: pointer;
}
<div class="formfield" contenteditable="true">Text <span>aa</span></div>
<div class="btn">get focus</div>
<script src="https://code.jquery.com/jquery-1.12.3.js" integrity="sha256-1XMpEtA4eKXNNpXcJ1pmMPs8JV+nwLdEqwiJeCQEkyc=" crossorigin="anonymous"></script>
@Bacco as you think work with contenteditable, but, I have not tested, I will test, if it does not work I withdraw the comment.
– LeAndrade
@Bacco really those answers did not correspond with contenteditable.
– LeAndrade