jQuery TE——相容IE6的輕量級文字編輯器外掛程式

來源:互聯網
上載者:User

標籤:style   http   io   os   ar   使用   java   sp   檔案   

一、jQuery TE簡介
  • 官方頁面
  • 項目Demo
  • 官方文檔

jQuery TE是一款輕量級的jQuery的網頁編輯器外掛程式,壓縮後只有19.5KB,相容性非常好的所見即所得 (WYSIWYG)的文字編輯器。經過測試,相容IE6。

而且,你可以自訂它的樣式,寫一些css,不僅僅是textarea,你可以將多種標籤變成一個編輯器,比如span,或者p等。

相容性:IE6+、chrome、Firefox、Opera、Safari、Yandex Browser等

二、如何使用 1、引入檔案

這裡方便使用,引入的為CDN地址,你也可以去官網下載,裡面有Demo。

<link href="http://cdn.bootcss.com/jquery-te/1.4.0/jquery-te.min.css" rel="stylesheet"><script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script><script src="http://cdn.bootcss.com/jquery-te/1.4.0/jquery-te.min.js"></script>
2、定義編輯器

你可以使用適合標籤來定義編輯器,當然只要有一個class值與下面的script標籤中的對應即可。但平時,我們建立編輯器,一般使用textarea標籤。

<textarea name="textarea" class="jqte-test"></textarea>

或者,是這樣(使用一種即可):

<input class="jqte-test" name="text2" value="Articles should be in here"><div class="jqte-test" name="text3">Articles should be in here</div><span class="jqte-test" name="text4">Articles should be in here</span><p class="jqte-test" name="text5">Articles should be in here</p>
3、建立編輯器
<script>        $(‘.jqte-test‘).jqte();    </script>

到現在,一款編輯器就配置好了,當然了,前面我們說,你可以自訂它的很多樣式,那麼,下面,我們就來嘗試一下。

三、自訂 1.禁用或啟用某個功能

比如,我不想使用加粗的按鈕,在選擇項中消失,這時候就可以在js中寫,如下:

<script>        $(‘.jqte-test‘).jqte({            "b":false        });    </script>

關於可以啟用會禁止多少個功能按鈕,可以參考其官方文檔。下面貼個圖,一些功能我也沒試:

2.事件

jQuery TE提供了三個基本事件:

change:文字框內容改變時觸發focus:聚焦在文字框時觸發blur:文字框失去焦點時觸發

使用方法:

<script>        $(‘.jqte-test‘).jqte({            blur: function(){                         alert("失去焦點");                     }        });    </script>

其他調用方法類似,只需改變blue為change或者focus,然後在function中寫jquery語句便可以了。

3.其他

除了上面的一些功能外,該編輯器支援鍵盤快速鍵操作,如下:所有快速鍵四Ctrl+xx的形式,比如,字型加粗就是“Ctrl+B”

jQuery TE——相容IE6的輕量級文字編輯器外掛程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.