2016-10-03 35 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一樣嗎?你能舉一個你的代碼的例子嗎? –