I’ve the following html structure and the following js I would expect, that after the second click on .start, the console would show “Test”, but it doesn’t… Can you tell me what I’m doing wrong? Thanks in advance! Answer While you have your answer, I don’t think the essential point has been made in any of the answers so far,
Tag: custom-data-attribute
jQuery sort different class elements by attribute
There is two arrays that display information appending elements to the document. They are being printed in ascending order, but when it comes to organize them all, I can’t organize them individually by data attribute. This function does the sort but can’t mix different element classes: Before the above code this is where I print the two different element classes
Get parent data element from dragged element – Drag en drop function
I am trying to retrieve a parent data attribute data-date of the dragged object in JavaScript. So i want to receive the data-date attribute <td> from where the div “drag me” was dragged from. HTML example: I am able to retrieve the dropped data-date attribute, but cant figure out how to retrieve the dragged from data-date attribute. JS From and
how to get query selector data attribute in javascript?
I have a custom JS function that creates/inject a custom link into all elements in the page when it loads. Before manipulation: and now this custom function manipulates the element: The newly manipulate element: How can I get the data-src attribute from the IMG tag and inject it into my newly created custom link function? I should use a var?
Perform different actions with a button based on the data attribute
I have one button. His first action is to stop a video. Then it’s icon change and data-status too. His second action is to reload the page. The problem is that I can’t do the second even if I code some conditions. Sometimes it don’t do anything, sometimes the second action comes at the same time of the first one.
jQuery: Select data attributes that aren’t empty?
I’m trying to select all elements that have a data-go-to attribute that is not empty. I’ve tried $(‘[data-go-to!=””]’) but oddly enough it seems to be selecting every single element on the page if I do that. Answer try UPDATE: For the sake of not leading anyone astray, this answer will work in older versions of jQuery but is not future-proof.