![](/img/trans.png)
[英]on selection of checkbox display textarea. if it's not selected textarea value should empty
[英]Once click the button the content of the textarea should be display to another div or textarea. and first textarea should be clear after clicking.
就像文章發布者可以發布他們的文章一樣。 單擊它們后,按鈕必須顯示在下面。但是在textarea或div中,不需要文本編輯功能。 一旦單擊該按鈕,它必須再次顯示在下方,他們可以發布(多個)。
//<![CDATA[ bkLib.onDomLoaded(function() { nicEditors.allTextAreas() }); //]]> </script> <script type="text/javascript"> function doMagic() { var homeTown = document.getElementById("hometown").value; document.getElementById("comment").value = homeTown; }
<script src="http://js.nicedit.com/nicEdit-latest.js"></script> <textarea name="area2" id="hometown" style="width: 100%;"> Some Initial Content was in this textarea </textarea> <input type="button" class="btn btn-success" value="publish" onClick="doMagic();" style="margin-top:20px; margin-bottom:20px;"></input> <div class="container"> <div class="col-md-12"> <textarea id="comment" style="background-color:#000;"></textarea> </div> </div>
bkLib.onDomLoaded(function() { nicEditors.allTextAreas() }); function doMagic() { var homeTown = document.getElementById("hometown").value; var ed = nicEditors.findEditor('comment') ed.setContent(homeTown); }
<script src="http://js.nicedit.com/nicEdit-latest.js"></script> <textarea name="area2" id="hometown" style="width: 100%;"> Some Initial Content was in this textarea </textarea> <input type="button" class="btn btn-success" value="publish" onClick="doMagic();" style="margin-top:20px; margin-bottom:20px;"></input> <div class="container"> <div class="col-md-12"> <textarea id="comment"></textarea> </div> </div>
從NiceEdit的文檔中可以很明顯地看出,要在已經用niceedit初始化的文本區域中設置值,您需要使用OOTB函數。 因此,請不要使用香草JS,而應使用
var ed = nicEditors.findEditor('comment');
ed.setContent(homeTown);
您只需要在該文本區域中顯示嗎? 似乎該插件會將該頁面中的所有文本區域轉換為編輯器。
如果需要,您可以只在div本身上顯示。
//<![CDATA[
bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
//]]>
</script>
<script type="text/javascript">
function doMagic() {
var homeTown = document.getElementById("hometown").value;
document.getElementById("comment").innerHTML = homeTown;
}
並將ID分配給div。
<script src="http://js.nicedit.com/nicEdit-latest.js"></script>
<textarea name="area2" id="hometown" style="width: 100%;">
Some Initial Content was in this textarea
</textarea>
<input type="button" class="btn btn-success" value="publish" onClick="doMagic();" style="margin-top:20px; margin-bottom:20px;"></input>
<div class="container">
<div class="col-md-12" id="comment">
</div>
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.