Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select elements using display:block

This is the html content from which I want to select all elements inside report having display block using jQuery $("#report:visible") does not work for me.

<div id="report">
        <div id="p1" style="display: block;">
            <input id="pname1"  type="checkbox" name="report1">
            <input id="pname2"  type="checkbox" name="report2">
        </div>
        <div id="p2"  style="display: none;">
            <input id="pname1"  type="checkbox" name="report1">
            <input id="pname2"  type="checkbox" name="report2">
        </div>
        <div id="p3"  style="display: none;">
            <input id="pname1"  type="checkbox" name="report1">
            <input id="pname2"  type="checkbox" name="report2">
        </div>
            <div id="p4"  style="display: block;">
            <input id="pname3"  type="checkbox" name="report1">
            <input id="pname4"  type="checkbox" name="report2">
        </div>
</div>
like image 522
Abhishek Avatar asked Nov 28 '22 17:11

Abhishek


1 Answers

Maybe you can use this piece of jQuery :

$("#report div:visible").each(function() { 
    console.log($(this).attr('id')); 
});

Or this one :) ?

$("#report div:visible");
like image 171
Benz Avatar answered Dec 05 '22 13:12

Benz