我正在添加WYSIWYG
文本编辑器。在这里,我只希望最后一个textarea显示WYSIWYG
文本编辑器,前三个文本编辑器应该是相同的。如何编辑selector
以便它只影响下面给出的第4个文本编辑器。
<script src="http://tinymce.cachefly.net/4.1/tinymce.min.js"></script>
<script>tinymce.init({selector:'textarea'});</script>
<textarea>Easy! You should check out MoxieManager!</textarea>
<textarea>Easy! You should check out MoxieManager!</textarea>
<textarea>Easy! You should check out MoxieManager!</textarea>
<textarea>Easy! You should check out MoxieManager!</textarea>
答案 0 :(得分:1)
如果您不想修改标记,请尝试以下操作:
<script>tinymce.init({selector:'textarea:last-child'});</script>
还可以使用jQuery:
<script>tinymce.init({selector:'$("textarea").last()'});</script>
......或
<script>tinymce.init({selector:'$("textarea").eq(3)'});</script>
答案 1 :(得分:0)
使用此代码:
<script src="http://tinymce.cachefly.net/4.1/tinymce.min.js"></script>
<script>tinymce.init({elements :'txtwysiwyg'});</script>
<textarea>Easy! You should check out MoxieManager!</textarea>
<textarea>Easy! You should check out MoxieManager!</textarea>
<textarea>Easy! You should check out MoxieManager!</textarea>
<textarea id="txtwysiwyg">Easy! You should check out MoxieManager!</textarea>
答案 2 :(得分:0)
您需要为textarea
中的一个提供一个ID,以便您可以在tinyMCE初始化中引用它。我建议花一些时间阅读他们有很多很好例子的文档
http://www.tinymce.com/wiki.php
<script src="http://tinymce.cachefly.net/4.1/tinymce.min.js"></script>
<script>tinymce.init({selector:'#tinyMCE'});</script>
<textarea>Easy! You should check out MoxieManager!</textarea>
<textarea>Easy! You should check out MoxieManager!</textarea>
<textarea>Easy! You should check out MoxieManager!</textarea>
<textarea id="tinyMCE">Easy! You should check out MoxieManager!</textarea>