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: 106
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
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
-
How to get text from javascript alert box
JavaScript - jQuery - Ajax
First post
Good evening (dutch-time) I have a javascript what can copy text to a clip-board + it has a button to show the item-list in a alert-box.
But can`t...
Last post
Thanks for the support I tried already things with history + f_print
also studied those a little before I asked coursesweb but I shall
when my head...
-
Javascript add different text to each minute of hour
JavaScript - jQuery - Ajax
First post
Hello Coursesweb I`m unknown with javascripts ????
I would like to add function minutes to this script
on each minute an diferent text added to...
Last post
Hello,
Try the following script.
<div id='addtxtmin' style='color:#00d; font-size:20px; font-weight:700'></div>
<script>
const...
-
Adding content from a Div into an input text field
JavaScript - jQuery - Ajax
First post
I still don`t understand how I can get the results from a div into a text input form field ?
<div id= div2 > Content </div>
I...
Last post
Thanks Chief for all your support....
My URL-extractor is working
in the comment-system
-
Textarea with buttons for format text and smiles
Scripts from this website
First post
I`m a bit furter with my comment + badword-filter & hashtag-system
But my problem I can`t see the bbcode I only see HTML tags into my textarea...
Last post
In the archive with that JS script there is a file form.html. In that file there are instructions and a demo with textarea and bbcode.
Open that...
-
Reverse the characters added in text field
JavaScript - jQuery - Ajax
First post
I have the following html and JavaScript code. An input text box and a button.
<input type='text' id='backwards-input'>
<button...
Last post
Try use and study the following code:
<input type='text' id='backwards-input'>
<button id='backwards-button'>Button</button>...