Instead of searching the full DOM for the specific classes we are looking thru $module element which is already in memory and a fraction of the full DOM. var $module = $(“[data-module=Cars]”); Just by looking at this code it would be easy to assume that data-module=Cars is related to javascript module called Cars.  intuio GmbH, use data attributes to find HTML elements with JS, Roy Tomeij analyzes the exact differences in performance, Don’t use class names to find HTML elements with JS, Follow-up: Don’t use class names to find HTML elements with JS, About HTML semantics and front-end architecture, The first thing is “there are no more appropriate attributes or elements” and for specific data that corresponds to a specific (and not standard) attribute of the element that may or may not serve as a way to find or filter that (or thoose) specific element(s) is exactly that. Classes can be used to select more than 1 item but leaves developers clueless how things are wired up. The W3C specification defines the data attribute as follows: There is many things wrong with this idea the biggest reason is that css is meant for styling purposes. I use prefixes: ‘trigger-‘ for pre-existing classes and ‘js-‘ for classes added by js. var $rentalList = $module.find(“[data-rental]”); How this is faster: var $truckList = $(“.trucks”); Add Comment Read More. Falls das Attribut nicht existiert, wird es erzeugt. Using data attributes does not prevent multiple such third party libraries from interfering with each other, and such occurrences indicate a poorly written library. The index starts at 0. How to get an attribute value in jQuery? In addition to the information below, you'll find a how-to guide for using HTML data attributes in our article Using data attributes. With the introduction of HTML5, JavaScript developers have been blessed with a new customizable and highly flexible HTML tag attribute: the data attribute. Period. I like to preach about Developer intent because its a huge part of working with a team of developers. According to him, this is only an issue for very large and complex sites. Selecting the Single element. Data attribute while passing values such as config params is useful it can be used to select 1 or multiple elements. Get the value of the target attribute of an element: Get the value of the onclick event attribute of a