Make a ContentEditable div read-only?

后端 未结 4 905
闹比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:29

    To make all controls within a div locked or unlocked, try this :

    ....

    lockDiv = function(lockIt){
        if(lockIt){    
            $('#lockableDiv :input').attr('readonly', true);
        }else{
            $('#lockableDiv :input').removeAttr('readonly');
        }
    }
    

提交回复
热议问题