Is there a selector to exclude display: none elements?

前端 未结 6 2188
醉话见心
醉话见心 2021-02-19 23:22

I want to select only whose parents have display: block and exclude those whose parents have display

6条回答
  •  我寻月下人不归
    2021-02-20 00:00

    You can check with jquery. The code below means

    "Get all buttons, filtered by ones whose parent is visible on page", loop through and print html of each one.

    $(document).ready(function(){
    $(":button").filter(function() { return $(this).parent().is(':visible') 
           }).each(function(){
    		      console.log($(this).html());
    		});
    });
    
    

    My name is someone.

    I live somewhere.

    My best friend is someone.

    Who is your favourite:

提交回复
热议问题