How to Find a Specific Data Attribute Using Zepto (or JQuery)

This method is exactly the same as JQuery. Let’s say you called your data attribute recordId:

Zepto("#the-div").data("recordId", 0);

You can target that div with the data attribute that Zepto (or JQuery) created simply by doing the following:

var el = Zepto("[data-record-id='0']");

If you have added the same data attribute to different elements across your web app, for example:

Zepto("#the-div").data("recordId", 0);
Zepto("#the-span").data("recordId", 0);

Then, you can target the specific div (or whatever element) by doing the following:

var el = Zepto("[data-record-id='0']#the-div");