So I have an anchor which looks like
<a href="http://something.com/something/" class="dropdown-toggle">something</a>
and I want to add
data-toggle="dropdown"
so that it ends up looking like
<a href="http://something.com/something/" class="dropdown-toggle" data-toggle="dropdown">something</a>
I tried
$(".dropdown-toggle").data("toggle", "dropdown");
But it isnt adding anything cheers
type = 'image'; button. onclick = function () { RemoveItem(this); }; button. style. marginLeft = '70px'; button.
Just add data-toggle="collapse" and a data-target to element to automatically assign control of a collapsible element. The data-target attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you'd like it to default open, add the additional class in.
You can use attr() jquery method to add the attribute.
Live Demo
$(".dropdown-toggle").attr("data-toggle", "dropdown");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With