Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable HTML input without disabling mouse events

Tags:

html

css

Is it possible to disable an HTML input while keeping mouse events?

I know that disabled="disabled" also stops events from being evaluated. What I need to do is disable clicking on the input element, but still recognize the onmouseover and onmouseout events (for switching background images).

Note that I am not searching for a workaround like making it look disabled with CSS or something like that. I want to actually make it impossible to be clicked (like clicking on an image), but I can NOT just use an image instead.

like image 894
Raimund Krämer Avatar asked Dec 27 '25 23:12

Raimund Krämer


1 Answers

Readonly?

 <input readonly="readonly" type="text">

You can preserve mouse events, but will be impossible to fill with keyboard.

like image 165
Marcos Pérez Gude Avatar answered Dec 30 '25 13:12

Marcos Pérez Gude



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!