In my JavaScript I use the css selector [style="display:none"] and the code works in Chrome, Firefox, Opera and Safari (on Windows) as expected.
However in Internet Explorer (version 11) it works unfortunately wrong.
For testing:
Just click on the buttons (e.g. #visible_elements_count) in Chrome and then click on the buttons in Internet Explorer. You will experience different return values.
HTML:
<section>
<ul>
<li>visible Element</li>
<li style="display:none">invisible Element</li>
<li>visible Element</li>
</ul>
</section>
<button id="all_elements_count">all elements</button>
<button id="visible_elements_count">visible elements</button>
<button id="invisible_elements_count">invisible elements</button>
<!-- JAVASCRIPTS -->
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$("#all_elements_count").click(function () {
var counter = $("section ul li").length;
alert(counter);
});
$("#visible_elements_count").click(function () {
var counter = $("section ul li:not([style='display:none'])").length;
alert(counter);
});
$("#invisible_elements_count").click(function () {
var counter = $("section ul li[style='display:none']").length;
alert(counter);
});
</script>
Sources: I read everything about selectors! and still can not solve this problem.
Any help is appreciated!