I have a html table with rows like this:
<tr class="d-flex linkObj" style="display: flex !important;">
<th class="col-4">
<div class="document-icon">
<i class="far fa-file-code"></i>
</div>
<span class="file_data">Tobier - WordPress Tutorials, SEO Tools und vieles mehr<br>
<span class="analyse_url quelle">https://tobier.de</span>
</span>
</th>
<th class="col-2">
Bild: https://tobier.de/media/2018/06/logo-4.png
</th>
<th class="col-2">
<i class="far fa-check-circle text-success"></i> follow
</th>
<th class="col-4">
<div class="document-icon">
<i class="far fa-file-code"></i>
</div>
<span class="file_data">https://tobier.de<br>
<span class="analyse_url ziel">https://tobier.de</span>
</span>
</th>
</tr>
i am iterate through all rows and want check the <span class="analyse_url ziel">
value.
so my iterate looks like this:
jQuery('.linkObj').each(function (i, obj) {
//if span value == 'https://tobier.de' do this:
obj.style.setProperty("display", "none", "important");
});
all my attempts to access the span from the object failed, can you help me get the content of the spans?
3
Answers
To access the
span
within thetr
, you can usefind()
within youreach()
. Then you can perform the check on thetext()
of that element and callhide()
on thetr
, like this:Note that you can make this slightly more succinct by providing a boolean value to
toggle()
:It is very important that you put the tag TR inside a TABLE otherwise it does not work. And that’s the code.