2016-10-03 72 views
-1

enter image description here我已经使用CKEditor为我的文本框造型.i已经添加到我的文本框中,但是如果我想从文本框中获取我的id,那么它给出未定义的值。任何人都可以帮助我解决我的查询,这对我有所帮助。我怎样才能使用ckeditor文本框的id(使用ajax)

 <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(); 
 
\t \t  alert(topic_describe); 
 
       
 
       }); 
 
      </script>
<textarea name="editor1" id="add_val"></textarea> 
 
    <br/> 
 
\t <a href='#' class="btn btn-success" style=' padding-top:10px;' id='submit' ><strong><span class='glyphicon glyphicon-pencil'></span>&nbsp;Add Post </strong></a>
,你可以看到图片后,点击该按钮的输出是不确定的。

+0

你能对你正试图在这里实现的目标更加明确:做ü希望的textarea的'id'或者其内部的内容。没有附加图片,也没有任何操作在'添加帖子'链接/按钮上定义。 –

+0

谁在我的文章中使用投票?请告诉我 –

+0

实际上,我想要Textarea的内容并用于通过使用ajax在另一个页面上重定向。 –

回答

0

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

  1. 你是你使用它们之前,最好在<head>
  2. 文本区id加载jquery.jsckeditor.js是一样的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>

+0

基本上,我想找出编辑器的id而不管文本区'id' –

+0

不是编辑器和textarea一样吗?你能举一个你的代码的例子吗? –