According to the DOC ,
Elements are considered visible if they consume space in the document. Visible items have a width or height that is greater than zero.
I checked the option tag, it seems that there is no css property with it to ignore its space from the DOM. Although, while I select the option
tag using the :visible
selector, it does not select anything. It seems mysterious to me.
HTML:
<select> <option selected=true>test</option> <option>test1</option> <option>test2</option> <option>test3</option> <option>test4</option> </select>
JS:
console.log($('select option:visible').length);
Can someone explain reliably what is happening behind this?
source share