質問する
985 次
3 に答える
3
于 2013-06-22T23:40:26.663 に答える
0
これは、同じ問題に直面していて学びたい人のために私が達成したかったことです.
CSS:
.TextArea {
width: 300px;
height: 30px;
border: 1px solid rgb(204, 204, 204);
margin: 0px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
Padding: 5px;
color: #444;
-webkit-text-fill-color: transparent;
resize: none;
outline: 0;
z-index: 2;
background-color: transparent;
position: relative;
font-family: Arial,Helvetica,Verdana,sans-serif;
line-height: 1.28;
font-size: 12px;
}
.DivTag {
position: absolute;
z-index: 1;
border: 1px solid rgb(204, 204, 204);
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background-color: white;
zoom: 1;
border-radius: 5px;
padding: 5px;
width: 300px;
height: 30px;
line-height: 1.28;
overflow: hidden;
white-space: pre-wrap;
word-wrap: break-word;
font-family: Arial,Helvetica,Verdana,sans-serif;
font-size: 12px;
}
.boldTag {
background: #d8dfea;
background: -webkit-gradient(linear, center top, center bottom, from(#dce6f8), to(#bdcff1));
background: -webkit-linear-gradient(#dce6f8, #bdcff1);
-webkit-border-radius: 2px;
-webkit-box-shadow: 0 0 0 1px #a3bcea;
font-weight: normal;
}
HTML:
<div class = "DivTag"></div>
<textarea class="TextArea"></textarea>
Jクエリ:
$('.TextArea').keyup(function () {
var txt = $('.TextArea').val();
$(".DivTag").text(txt);
var DivTag = $(".DivTag").text();
var $div = $(".DivTag");
$div.html(DivTag.replace(/\s(\#[a-zA-Z]\w*)/g, " <b class='boldTag'>$1</b>"));
text = $(".DivTag").text();
text = text.replace(/\s+/g, " ");
text = text.trim();
});
于 2013-06-25T11:59:52.133 に答える