I'm trying to match visible object's text but ignore not visible ones. By the way I need HTML code.
Here is my codepen.
Here is my HTML:
<div class="main">
<div class="a">Hello</div>
<div class="hid">Hello</div>
<div class="b">Hello</div>
<div class="hid2">Hello</div>
<div class="c">Hello</div>
<div class="hid3">Hello</div>
<div class="hid4">Hello</div>
</div>
My CSS:
.hid, .hid2, .hid3, .hid4{
display: none;
}
My JavaScript:
var regEx = /Hello/g;
var main = $('.main').html();
var matches = main.match(regEx);
console.log(matches);
Actually I want to exclude invisible elements without removing them from page. I want these HTML codes at the result:
<div class="a">Hello</div>
<div class="b">Hello</div>
<div class="c">Hello</div>
I don't want to remove the hidden objects because I'll use them interactively. I just want to exclude them from match. We can use jQuery.
Thank you from now.