How to remove an attribute in D3.js?

JavascriptDomAttributesd3.js

Javascript Problem Overview


Can I in D3.JS remove an attribute? I've added it using .attr("disabled", "disabled") and now I am looking for something similar to jQuery's .removeAttr("disabled", "disabled"); to remove it again. Useful for <button> and <option>. I've tried using the .remove() but that removes the entire object not the attribute.

Javascript Solutions


Solution 1 - Javascript

From the API documentation for attr

> A null value will remove the specified attribute

So it looks like you want .attr('disabled', null).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionbonnaView Question on Stackoverflow
Solution 1 - JavascriptIan RobertsView Answer on Stackoverflow