繁体   English   中英

如何将文本框的 id 与 ckeditor 一起使用(与 ajax 一起使用)

[英]how can I use the id of textbox with ckeditor (using with ajax)

在此处输入图片说明 我已经将 CKEditor 用于我的文本框样式。我已经在我的文本框中添加了,但是如果我想从文本框中获取我的 ID,那么它会给出未定义的值。 任何人都可以帮助我解决我的查询,这对我有帮助。

 <script src="//cdn.ckeditor.com/4.5.11/standard/ckeditor.js"> </script> <script> CKEDITOR.replace( 'editor1' ); </script> <script> $(document).ready(function(){ var topic_describe=$("#add_val").html(); alert(topic_describe); }); </script>
 <textarea name="editor1" id="add_val"></textarea> <br/> <a href='#' class="btn btn-success" style=' padding-top:10px;' id='submit' ><strong><span class='glyphicon glyphicon-pencil'></span>&nbsp;Add Post </strong></a>
正如您在单击按钮后在图像中看到的那样,输出未定义。

你的代码看起来不错。 只需验证以下几点:

  1. 您在使用之前加载jquery.jsckeditor.js ,最好在<head>
  2. Textarea id与您的 JS 中的相同

如果是这样,您是否遗漏了任何其他可能相关的细节?

查看:

 $(document).ready(function() { CKEDITOR.replace('editor1'); var topic_describe = $("#add_val").html(); alert(topic_describe); });
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdn.ckeditor.com/4.5.11/standard/ckeditor.js"> </script> <textarea name="editor1" id="add_val">************* This is the Text inside the Textarea *************</textarea> <br/> <a href='#' class="btn btn-success" style=' padding-top:10px;' id='submit'><strong><span class='glyphicon glyphicon-pencil'></span>&nbsp;Add Post </strong></a>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM