简体   繁体   English

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

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

在此处输入图片说明 I have used the CKEditor for my textbox styling .i have done to add in my textbox but if I want to get my id from the textbox then it gives the undefined value .我已经将 CKEditor 用于我的文本框样式。我已经在我的文本框中添加了,但是如果我想从文本框中获取我的 ID,那么它会给出未定义的值。 Anyone can help me to resolve my query it would be helpful for me.任何人都可以帮助我解决我的查询,这对我有帮助。

 <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>
as you can see in image after click the button the output is undefined . 正如您在单击按钮后在图像中看到的那样,输出未定义。

Your code looks fine.你的代码看起来不错。 Just verify below points:只需验证以下几点:

  1. You are loading the jquery.js and ckeditor.js before you are using them, preferably in the <head>您在使用之前加载jquery.jsckeditor.js ,最好在<head>
  2. Textarea id is the same as in your JS Textarea id与您的 JS 中的相同

If so, are you missing any other details which might be relevant?如果是这样,您是否遗漏了任何其他可能相关的细节?

Check out:查看:

 $(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