disable text selection except input

前端 未结 3 1875
隐瞒了意图╮
隐瞒了意图╮ 2021-01-14 01:01

I\'ve got this snippet of code to disable all text selection. How would I go about disabling all text except for input? I tried $(\'* :not(input)\').disableTextSelec

3条回答
  •  孤独总比滥情好
    2021-01-14 01:08

    $(document).bind('mousedown selectstart', function(e) {
        return $(e.target).is('input, textarea, select, option, html');
    });
    

    Thanks to @user2873592, who mentioned that adding html here would fix the chrome scroll bar can't be dragged issue.

提交回复
热议问题