Change certain element classes to specific classes if certain other element is present

Change certain element classes to specific classes if certain other element is present

Hi there I'm trying to code a blog theme which will have tags etc so wat I'd like is for certain classes of mostly parent divs to change when tagged with something (example below).


classes are spans (using bootstrap)



html



<div id="a" class="span6">

</div>



<div id="b" class="span6">



<a class="taglink">[tag]</a>



</div>



What I'd like is for div a and b's classes to change to say span12, and *only* them and no other parent/adjacent/child etc divs.



This is so that when I tag the post with certain tags I'd like some of its layout properties to change (via its css class)