How to add data-attributes with no value to elements

custom-data-attribute, html, jquery, zurb-foundation

Solution

With jQuery, you would just set it to an empty string:

$('.alert-box').attr('data-alert','');

Problem

I want to use jQuery to create Foundation alert boxes (docs here). The alert box div takes a `data-alert`, attribute as in: ``` <div data-alert class="alert-box"> ``` I know you can add attributes to elements using `.attr()`, `.data()`, `.prop()`, etc., but how can I add something like `data-alert`, an attribute that doesn't have a value?

Original source