user4756836 user4756836 - 1 year ago 66
AngularJS Question

Add class to multiple elements in AngularJs

I am trying to add a class to multiple divs to change it's background color.


<div class="span6">
<div class="heading">Heading 1</div>

I am currently using this:


My issue is that... there are multiple div's with this heading but it is changing the color of only the first occurrence of that div. How can I have it so all the divs with that class add that css styling.

Answer Source

document.querySelector selects the first element that matches the query. querySelectorAll should achieve the result you want.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download