Hide element if data contains specific text
Place to talk about website HTM elements, CSS style and design, and get help with HTML, CSS codes.
-
Marius
- Posts: 107
Hide element if data contains specific text
Is there a possibility to hide HTML elements if the 'data-' attribute contains a specific piece of text?
For example: Hide the Divs that it's data contains "-en".
Code: Select all
<div class='check' data-value='example-en'></div>
<div class='check' data-value='check-en'></div>
<div class='check' data-value='example2-en'></div>
<div class='check' data-value='check-fr'></div>
Thanks!
MarPlo
Posts: 186
You can do this with either CSS or Javascript.
CSS:
Code: Select all
/* with specified elements */
div[data-value*='-en'] {
display: none;
}
/* or global */
[data-value*='-en'] {
display: none;
}
And if you wanted to do it based on data in classes name.
And JS:
Code: Select all
document.querySelectorAll('[data-value*="-en"]').forEach((elem) => elem.style.display ='none');
Similar Topics
-
Toggle Show Hide-0Javascript
PHP - MySQL
First post
Hello CoursesWeb,
I have sql document with 4 results from-out database.
But I can`t open the results from the post_id ????
What do I do wrong...
Last post
Try the following code. See the differences.
<?php
echo '<div id= idd11'. $row .' style= display:none; >';
echo $row ;
echo...
-
Speech to text without https
General Forum
First post
Pleasant Coursesweb,
Is their anything posible without https for speech to text fill-in ?
Or must I turn my SSL document on the XAMPP-server ?
Last post
Hello,
I don't know about speech to text fill-in.
Anyway, I want to inform you that this forum will be closed for register or posting.
Any...
-
Link inline with the text
HTML - CSS
First post
Hi members I'm looking for the script for a link <href> to another URL.
I give part of my text and the link as it is now on my page:
and...
Last post
Hello,
In your case, put both the text and the link inside the <p> tag.
<p>and there where useful, supplemented with comments, tips...