Link to Code: http://jsfiddle.net/MuHvy/
Javascript:
$(document).ready(function () {
$(".addTag").click(function () {
$('.questao').html($('.questao').html() + ' <span contentEditable="false" class="tagResp"> </span> ');
$('.questao').focus();
});
});
Span Css:
border:2px solid #dadada;
border-color:#9ecaed;
border-radius:7px;
display: inline-block;
height: 10px;
width: 50px;
padding:5px;
margin-top:3px;
box-shadow:0 0 10px #9ecaed;
white-space:nowrap;
This code snippet is designed to create a tag on the same line when a button is clicked.
Issue: The created tag by jQuery jumps to a new line after the second line, instead of staying in the same line.
Example:
~INCORRECT~
randomtext randomtext <span>tag</span> <br>
randomtext <br>
<span>tag</span>
Should look like this:
randomtext randomtext <span>tag</span> <br>
randomtext <span>tag</span>
Another question is:
Is it possible to focus on the last line? The .focus() function in jQuery goes to the start of the text, but ideally should go to the end.
Appreciate any help or suggestions!