Set attribute without value
The attr() function is also a setter function. You can just pass it an empty string. $(‘body’).attr(‘data-body’,”); An empty string will simply create the attribute with no value. <body data-body> Reference – http://api.jquery.com/attr/#attr-attributeName-value attr( attributeName , value )