How to prevent user from typing in text field without disabling the field?

前端 未结 11 1766
不思量自难忘°
不思量自难忘° 2021-01-31 06:58

I tried:

$(\'input\').keyup(function() {

   $(this).attr(\'val\', \'\');

});

but it removes the entered text slightly after a letter is enter

11条回答
  •  忘了有多久
    2021-01-31 07:27

    One other method that could be used depending on the need $('input').onfocus(function(){this.blur()}); I think this is how you would write it. I am not proficient in jquery.

提交回复
热议问题