1,112 questions
-1
votes
1
answer
43
views
Enforce format of data-attribute in vuejs, especially arrays
Is there a way to enforce the format of data-attributes?
Considering the following situation, the returned value is often a string – not an array. splitting is not always desirable, for instance, if ...
0
votes
1
answer
858
views
How to create a 'dynamic` data-attribute, a HTML element with a unique id, in Astro and pass the variables from server to client
In my Astro app I need to pass a variable from the server (frontmatter) to the client.
Like the documentation describe there are two options.
use data-attribute
use defineVars
As far as I can see ...
1
vote
1
answer
80
views
in Firefox querySelector with attribute while finding path in svg gives error
My code is working well in Chrome but not in Firefox.
When I search path element using querySelector with attribute Firefox gives an error that path is not found.
defs.appendChild(svgGradient);
const ...
-2
votes
1
answer
159
views
Can non data- attributes on custom elements become standard attributes?
In this article the author suggests using data- attributes in the design of a syntax highlighting web component.
The reason given is:
Technically speaking, the browser would let us write the ...
0
votes
0
answers
44
views
jQuery data-attribute to object with stringify reversing on newer versions
When retrieving the data-attribute on a HTML element I have run into a problem using jQuery.
I wish to manipulate the attributes and some elements have more data-attributes than others.
Using jquery-1....
3
votes
1
answer
925
views
Does React's type declarations e.g. React.HTMLAttribute<HTMLButtonElement> support the usage of custom data attributes out of the box?
I'm trying to create an object that can be spread into a React Component and this object has to include an HTML Custom Data Attribute.
import { HTMLAttributes } from 'react'
interface FooProps ...
0
votes
1
answer
96
views
On hover get img src specified in a `data` attribute, then add an img + path to another div
I have a javascript cursor, which does quite a few different things (hence a few different blocks of similar looking code), where on hover it will add classes to the cursor divs so it can be ...
-1
votes
1
answer
50
views
jQuery filtering divs based on multiple data attributes
I have multiple divs on a page, each with the following data attributes: data-one, data-two, data-three, data-four & data-five. The following code is creating a filterList array like so: ['one-...
2
votes
0
answers
1k
views
React-Select: Add custom data attribute to Input
I use ReactJS v18.2 with react-select v5.7.
I want to add a custom attribute (e.g. data-test) to the input element of my <Select/> component, I could not find something like this in the docs.
...
1
vote
3
answers
1k
views
Is there a way to add a blank data attribute to an element using JavaScript?
I want to create an element like the following with JavaScript:
<div data-boolean-attribute></div>
Passing null or undefined to setAttribute() or the dataset property results in a value ...
0
votes
1
answer
834
views
Save custom form data in shopify customer table
I have pet website developed in shopify and I have requirement that create custom form in shopify and store custom form data in shopify default customer table. As shopify do not provide database ...
0
votes
1
answer
87
views
need to set a data-* with no value with vanilla js
i'm creating a list of links dinamically from the sections i have:
$sections.forEach(({ id, firstElementChild: { textContent } }) => {
const link = document.createElement('a');
link....
4
votes
1
answer
318
views
Can't pass array to HTML data attribute for Bootstrap tooltips
I'm using version 5.2 of Bootstrap. I'm trying to use the fallbackPlacements option of the Tooltips plugin. The problem is that fallbackPlacement takes an array, but doesn't seem to accept one through ...
0
votes
1
answer
705
views
How to convert custom dataset json file to yolov8 text file format in python
I pulled the class names and x,y points I needed from the json file and created a csv file. This csv file contains rows for multiple regions for each image. For example, while there are 5 regions for ...
0
votes
1
answer
87
views
Show/hide divs according to multiple data values
This has been driving me crazy. Couldn´t get a definitive answer from chatgpt nor reddit.
Maybe stackoverflow has someone who is willing to help me out or give guidance.
Description:
When button is ...
0
votes
0
answers
71
views
Show Div if any Selected options in Multi Select equal or are more than custom Data Attribute
I have a script that shows a Div (incorporating a checkbox) that shows if a data-attribute select dropdown selection is more than 18 (for age verification for that option). The problem is if you ...
0
votes
2
answers
271
views
How to add numbers following a condition in JavaScript
I have a list of articles with different categories (ex: aaa, bbb, ccc). I want to display the sum of the data-prices for each category
For example, I should have 3.20 for aaa, 10.20 for bbb, and 11....
0
votes
1
answer
233
views
Bootstrap Collapse element on a scroll event
I am developing an Angular application and am using Bootstrap 5.2.
I am using the Collapse component on a card and it works perfectly using the data attributes.
However, I want to trigger the collapse ...
0
votes
0
answers
73
views
JS: Using dataset vs using (adhoc) properties
I need to store data (a string) on a certain HTML node.
This can be done via the dataset object
document.body.dataset.foo = 'bar';
Given the nature of JS however, node instances are also (just) ...
-1
votes
1
answer
51
views
HTML data-attribute html element can't design directly
I've write some HTML data-attribute code and added HTML tag inside. But I can't design them without adding any class name.
For example; this is my data-attribute;
<div data-box="<h1 class='...
1
vote
3
answers
3k
views
How to check the order of elements based on data attributes in Cypress
Let say I have a parent div with the id of "container" and it has four children with specific data attribute named data-test. How do I check if each child is in the right order? Let's say ...
0
votes
2
answers
650
views
Javascript: manipulate data inside data attributes in HTML
I have a html/js code that takes data from a json and render it to html table. It has been working fine for a while. Recently the number of items being handled has greatly increased and can't afford ...
0
votes
1
answer
844
views
Data-attribute in Angular component
I understand that I can add a data-attribute to an element within my component like this:
<div [attr.data-my]="myDataValue">
But how can I add a data-attribute to the component itself?...
1
vote
2
answers
1k
views
Change div HTML content with attribute from button on click
I have some data attributes on buttons that I need to send as content to a div when those buttons are clicked. A part of my code until now is this:
function getDiscount() {
var buttons = ...
1
vote
2
answers
3k
views
Set data-* attributes of a div element in Vue.js
How can I set data-* attributes of a div dynamically via an array or object in Vue.js?
I found out that it is possible to set attributes dynamically via the data attributes or via calculated ...