필자가 아는 한, 텍스트 상자에서 텍스트의 일부 스타일 만 수정하는 것은 쉽지 않습니다. 그러나이 같은 것을 할 수있는 :
HTML
<span id="tags"></span><input id="enterTag" type="text" />
자바 스크립트/jQuery를
$('#enterTag').keydown(function(event) {
var tag = $(this).val();
// 188 is comma, 13 is enter
if (event.which === 188 || event.which === 13) {
if (tag) {
$('#tags').append('<span>' + tag + '</span>');
$(this).val('');
}
event.preventDefault();
}
// 8 is backspace
else if (event.which == 8) {
if (!tag) {
$('#tags span:last').remove();
event.preventDefault();
}
}
});
CSS
#tags span {
display: inline-block;
background: #6999c0;
color: #FFFFFF;
padding: 4px;
border: solid 1px #477eab;
margin-right: 4px;
}
예제 : http://jsfiddle.net/FishBasketGordo/xckjk/
jQuery를 사용해야합니까? – GolezTrol
아니요, 오직 선호. –