xh6547 2017-09-06 09:11 采纳率: 0%
浏览 3090

如何通过一个按钮动态的添加富文本编辑框

```


                <div style='width: 40%; height: 15px;float:left;'>
                        <font color='red' size='4'>文本规则说明:</font>
                        <div style='height: 200px; width: 95%;float:left;'>
                            <div>
                                <textarea id='ruleIntroduction' name='ruleIntroduction' rows='25' cols='80' ></textarea>
                                <script type='text/javascript'>CKEDITOR.replace('ruleIntroduction');</script>
                            </div>
                            <div style='height: 15px; float: left; width: 80%; margin-top: 12px;'></div>
                        </div>
                </div>  

                <div style='width: 40%; height: 15px;float:left;'>
                        <font color="red"  size="4">问题:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <div style='height: 200px; width: 95%;float:left;'>
                            <div>
                                <textarea id='rulequestion' name='rulequestion' rows='25' cols='80' ></textarea>
                                <script type='text/javascript'>CKEDITOR.replace('rulequestion');</script>
                            </div>
                             <div style='height: 15px; float: left; width: 80%; margin-top: 12px;'></div>
                        </div>
                </div>  

                <div style='width: 15%; height: 15px;float:left;'>
                    <div style='width: 100%; float: left;'>
                        <font color='red'  size='4'>规则答案:</font><br>
                        <input id='ruleanswer' name='ruleanswer' class='easyui-textbox' style='width: 100%;' />
                    </div>
                </div>

                <div style='width: 5%; height: 15px;float:right;'>
                    <div style='width: 25%; float: right; text-align: right;'>
                        <a href='javascript:void(0)' id='moreTextDiv' data-options='iconCls:"icon-add"' class='easyui-linkbutton'></a>
                    </div>
                </div>
            </div>
        </div>

$('#moreTextDiv').click(function() {
addnum++;
$('#textDiv').append("

"
+"
"
+"文本规则说明:
"
+"
"
+"CKEDITOR.replace(&#39;ruleIntroduction&#39;);&lt;\/script&gt;&quot;<br> +&quot;</div>&quot;<br> +&quot;<div style='height: 15px; float: left; width: 80%; margin-top: 12px;'></div>&quot;<br> +&quot;</div></div>&quot;<br> +&quot;<div style='width: 40%; height: 15px;float:left;'>&quot;<br> +&quot;<font color='red' size='4'>问题:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><div style='height: 200px; width: 95%;float:left;'>&quot;<br> +&quot;<div><textarea class='rulequestion' name='rulequestion' rows='25' cols='80' ></textarea>&quot;<br> +&quot;<script type='text/javascript'>CKEDITOR.replace(&#39;rulequestion&#39;);&lt;\/script&gt;&quot;<br> +&quot;</div>&quot;<br> +&quot;<div style='height: 15px; float: left; width: 80%; margin-top: 12px;'></div>&quot;<br> +&quot;</div></div>&quot;<br> +&quot;<div style='width: 15%; height: 15px;float:left;'><div style='width: 100%; float: left;'><font color='red' size='4'>规则答案:</font><br><input class='ruleanswer' name='ruleanswer' class='easyui-textbox' style='width: 100%;' /></div></div>&quot;<br> +&quot;<div style='width: 5%; height: 15px;float:right;'><div style='width: 25%; float: right; text-align: right;'>&quot;<br> +&quot;<a href='javascript:void(0)' id='lessDiv "<br> + addnum<br> +"' onclick='lessDiv(textDiv"<br> + addnum<br> + ")'></a></div></div>&quot;);<br> $(&#39;.ruleIntroduction&#39;).textarea();<br> $(&#39;.rulequestion&#39;).textarea();<br> $(&#39;.ruleanswer&#39;).textbox();<br> $(&#39;#lessDiv&#39; + addnum).linkbutton({<br> iconCls : &#39;icon-no&#39;<br> }); <br> });</p> <pre><code>![图片说明](https://img-ask.csdn.net/upload/201709/06/1504688953_29456.png) 通过点击后面的加号去动态的添加前面两个富文本编辑框和一个input,现在的问题是我点击后不会出现富文本编辑框里面的富文本编辑功能,只会添加一个textarea文本框。求大神给个思路 </code></pre>
  • 写回答

2条回答 默认 最新

  • Amo_lt 2017-09-06 09:55
    关注

    会添加textarea就说明你的js应该是正确的(具体没看)。但是不出现编辑器就说明的编辑器没配置好。你的页面里面引用了编辑器的js和css吗?,
    给你一个链接配置下在JSP里使用CKEditor和CKFinder

    评论

报告相同问题?

悬赏问题

  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面