Make a ContentEditable div read-only?

后端 未结 4 888
闹比i
闹比i 2021-01-18 01:47

So I want the features of a contenteditable div (text selection via keyboard being the main one), but I don\'t want to allow the user to edit the text - I presumed a r

4条回答
  •  礼貌的吻别
    2021-01-18 02:12

    I made a jquery solution/workaround. What is does is prevent the default action when a key is pressed:

    $(document).ready(function(){
      $("#editor").on("keypress", function(e) {
          e.preventDefault();
      });
    });
    
    

    Heading

    Test

提交回复
热议问题