There is a div #allContent that contains a few di开发者_运维百科vs within it. I would like to return the entire #allContent as a string, but remove any divs contained inside that are not visible.
I imagine this can probably be accomplished with some combination of filter(), :visible, and contents(), but I can't figure out exactly how to do it.
var clone = $('#allContent').clone()
                            .appendTo('body')
                            .find(':hidden')
                            .remove()
                            .end()
                            .remove();
var content = clone[0].outerHTML || $('<div>').append(clone).html();
Example: http://jsfiddle.net/ChXPB/3/
EDIT: Changed it to include the outerHTML div.
EDIT: Made it mostly chained, and repaired the Firefox shim.
Seems that we need to temporarily add the clone to the DOM.
This should do it:
$('#allContent').clone().find(':hidden').remove().end().html();
var allContentsHtml = '';
$('#allContent div:visible')
        .each(function() { 
                   allContentsHtml += $(this).html(); 
                   }
              );
$('#output').html(allContentsHtml );
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论