簡體   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