歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> jQuery獲取ckEditor的內容

jQuery獲取ckEditor的內容

日期:2017/3/1 10:09:10   编辑:Linux編程

在頁面中我載入了ckEditor作為我程序內容的輸入。

  1. <textarea name="content" id="content"></textarea><br>
  2. <input type="submit" value="submit" onclick="submit()">
  3. <script src="/ckeditor/ckeditor.js"></script>
  4. <script type="text/javascript">
  5. CKEDITOR.replace('content',{
  6. filebrowserBrowseUrl: '/ckfinder/ckfinder.html?Type=Files',
  7. filebrowserImageBrowseUrl: '/ckfinder/ckfinder.html?Type=Images',
  8. filebrowserFlashBrowseUrl: '/ckfinder/ckfinder.html?Type=Flash'
  9. });
  10. </script>

但是我頁面中是使用Jquery進行頁面提交的,但是直接用$("#content").val()是無法拿到content內容的。這裡我們需要使用ckEditor內置的函數來拿到這個內容。

  1. var oEditor = CKEDITOR.instances.content;
  2. var content = oEditor.getData();
Copyright © Linux教程網 All Rights Reserved