开发者

Disable Form Elements Using Event Capturing

开发者 https://www.devze.com 2023-01-09 10:07 出处:网络
Is it possible to make form elements unusable without setting the disabled property for each element?

Is it possible to make form elements unusable without setting the disabled property for each element?

My idea was this:

container.addEventListener('click', fu开发者_如何学Pythonnction(e) {
    e.stopPropagation();
    e.preventDefault();
}, true);

It behaves as intended for non form elements but it won't stop e.g. select elements from showing their options when clicked.


The select will be open after the mousedown event so this is the event you have to stop. http://jsfiddle.net/6K9Mj/

0

精彩评论

暂无评论...
验证码 换一张
取 消