Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should disabled <div> act?

Tags:

html

dom

input

I noticed the following bug when using $(selector).children().attr("disabled", "disabled") where the children happened to contain a <div>.

Fiddle

<div disabled="disabled">
    <input type="text" value="RAGE" />
</div>

Basic testing says FF4/Chrome enable the field. IE9 disables the field.

What is the expected behaviour?

Same for any other non form element (<input>, <select>, etc)

like image 786
Raynos Avatar asked Jun 10 '11 14:06

Raynos


People also ask

Does disabled work on div?

disabled isn't a valid property for div .

Can div be disabled react?

People also ask. How do you disable onClick event of div in react? The above code makes the contents of the div disabled, You can make the div disabled by adding the disabled attribute. Upon clicking the button you can change the state variable disabled as 'true'.

How do you make a div tag disabled?

To disable div element and everything inside with CSS, we set the pointer-events CSS property of the div to none . to disable pointer events on the div with pointer-events set to none with CSS.

Can we disable div in angular?

Div element cannot be disabled like form controls. You can disable form controls in div instead.


2 Answers

<div> elements do not have a disabled attribute according to the HTML specification. The expected behavior is to prevent your markup from validating correctly.

However, the new HTML5 specification allows for <fieldset> to have a disabled attribute, which disables any nested input fields. It's not widely supported yet though, so you won't be able to rely on this feature for a while.

like image 178
Dominic Barnes Avatar answered Sep 23 '22 13:09

Dominic Barnes


There is no disabled attribute for the div element. So it should have no effect.

like image 21
Quentin Avatar answered Sep 23 '22 13:09

Quentin