嘗試這樣的:
$(document).ready(function(){
$('#area').colorfy("markdown");
$('#area').text("value");//will be hidden you can see by inspecting the html
$('.area').html("value");// will be visible to you
});
注:我從看到的例子是它設置顯示:無到textarea的,但creates a div with the same class which is the class of text area
,並將其應用於對這些自己的CSS。
$(document).ready(function(){
$('#area').colorfy("markdown");
$("#click").click(function(){
\t $('.area').html("value");// will be visible to you
});
});
.area {
float: auto;
margin-left: auto;
margin-right: auto;
width: 200px;
max-width: 200px;
height: 200px;
border-color: black;
border-width: 2px;
border-style: solid;
padding: 8px;
font-size: 15px;
text-align: left;
}
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="http://cheunghy.github.io/jquery.colorfy/jquery.colorfy.js"></script>
<script type="text/javascript" src="http://cheunghy.github.io/jquery.colorfy/jquery.colorfy.markdown.js"></script>
<textarea id="area" class="area">
hi
</textarea>
<button id="click">click!</button>
嘗試互換他們,執行分配第一 – Sherlock
這可能是插件隱藏原來'textarea'並顯示其他HTML元素。因此,無論您使用插件API來更改文本,還是查找哪個「span」,「div」或其他顯示的文本真的放在哪個位置。 – Regent