I have the following div
with the following children
.
<div>
<img src="http://zferral.com">
<!--zferral is an invisible image analytics tool-->
<script>Some Comment</script>
</div>
There are 3 things in this div. A script
, an image
, and a comment
.
I need to know if their is something really inside this div and return a Boolean.
I need this to be available to jquery so I can hide the div if their is no visible children.
These should all return true
(bottom). The top example should return false
.
<div>
<img src="http://zferral.com">
<!--zferral is an invisible image analytics tool-->
<script>Some Comment</script>
<p>Hello</p>
</div>
<div>
<img src="http://zferral.com">
<!--zferral is an invisible image analytics tool-->
<script>Some Comment</script>
Hello
</div>
<div>
<img src="http://zferral.com">
<!--zferral is an invisible image analytics tool-->
<script>Some Comment</script>
<img src="anything other than zferral">
</div>
My Progress
I was using .clone()
to copy the div find all the script tags remove them.
I need to use regex to parse and remove all the comments.
Then use regex and .find to get images with zferral in the link.
Finally I should have a string <div></div>
and can confirm that it is empty.
I'm at a standstill and I don't exactly know if this is even the best approach.
part.additional = function(){
var test = $('.group[style="border: none;"]').clone().find('script').remove().end();
((jQuery('#content .group').length > 1 && jQuery('#content .group:nth-child(2)').find('*:visible').length !== 0)) ? jQuery('#content').clone(true).attr('id','additional').find('.group:first').remove().end().find('script').remove().end() : false ;
}
var a = jQuery('#content .group').length > 1;
var b = jQuery('#content').clone(true).attr('id','additional').find('.group:first').remove().end().find('script').remove().end().find('style').remove().end().find('[style="border: none;"]').removeAttr('style').end();
var c = jQuery('#content').clone(true).attr('id','additional').find('.group:first').remove().end().find('script').remove().end().find('style').remove().end().find('[style="border: none;"]').removeAttr('style').end().html().replace(/\n|\r|(\s\s)/g,'');
var d = '<div class="group"></div>' == c;
var e = (!d) ? b : false;