久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      H5富文本編輯器的詳細(xì)介紹

      使用H5的全局屬性contenteditable可以讓DOM元素及其子元素變的可編輯

      <div  contenteditable id="editor">     </div>

      樣式代碼

      html,  body {    overflow: hidden;    width: 100%;    height: 100%;  }* {    margin: 0;    padding: 0;  }  #editor {    width: 100%;    height: 100%;    outline: none;    padding-left: 15px;  }

      * chrome 49下測(cè)試有效

      以下方式使得用戶初始輸入的文本內(nèi)容在p元素的包裹下

      <div  contenteditable id="editor" spellcheck="false"><p><br/></p></div>

      默認(rèn)規(guī)則如下

      H5富文本編輯器的詳細(xì)介紹H5富文本編輯器的詳細(xì)介紹

      否則將直接作為#editor元素的文本節(jié)點(diǎn),即<div  contenteditable id="editor" spellcheck="false">文本內(nèi)容</div>同事點(diǎn)擊Enter將新增div元素,即<div  contenteditable id="editor" spellcheck="false">文本內(nèi)容<div></div></div>

      View Code

      #editor中的所用元素都是可被刪除的,當(dāng)#editor為空元素時(shí),用戶再次輸出內(nèi)容還會(huì)應(yīng)用默認(rèn)規(guī)則,這里要監(jiān)聽(tīng)這一狀態(tài),發(fā)生時(shí)將<p><br/></p>添入其中,并且定位光標(biāo)到p元素的最后

      定位光標(biāo)代碼

      function cursorToEnd(element){            element.focus();var range = window.getSelection();        range.selectAllChildren(element);      range.collapseToEnd();        }

      window.getSelection() IE9已經(jīng)支持

      不定位可能發(fā)生以下情況

      <div  contenteditable id="editor" spellcheck="false">      111111      <p><br/></p>  </div>

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)