Skip to content
Advertisement

Tag: attr

Set attribute without value

How do I set a data attribute without adding a value in jQuery? I want this: I tried: Everything else seems to add the second arguments as a string. Is it possible to just set an attribute without value? Answer The attr() function is also a setter function. You can just pass it an empty string. An empty string will

Advertisement