Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove an attribute in D3.js?

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.

like image 840
bonna Avatar asked Mar 10 '13 13:03

bonna


People also ask

Can you remove an attribute in Javascript?

Use the removeAttribute() to remove an attribute from a specified element. Setting the value of a Boolean attribute to false will not work; use the removeAttribute() method instead.

How do I delete attributes?

Perform the delete in one of the following ways: ◦ From the Attributes tab, select the attribute that you want to delete, and click the delete icon . ◦ Right-click on the attribute on the Attributes tab, and select Delete. ◦ On the attribute information page, select Delete from the Actions menu for the attribute.

What is enter () and exit () in d3 JS?

enter() function creates the initial join of the data with our DOM elements. Thus selecting only the elements that were not in the DOM yet. merge() function will select the DOM elements that did not exist in the DOM before and the ones that did. exit() function will select the DOM elements that are left from the join.

How do I delete all attributes?

To remove all attributes of elements, we use removeAttributeNode() method.


1 Answers

From the API documentation for attr

A null value will remove the specified attribute

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

like image 138
Ian Roberts Avatar answered Sep 23 '22 00:09

Ian Roberts