I understand that I cannot use addClass or removeClass with SVG and that I must use attr. But how can I toggle an attr of an SVG using jQuery. See my fiddle. I am trying to toggle the rotation of the arrow on click (see the commented out portion of the click function in my js section). Anybody have a better idea of how to do this?
My html
<div class="col-md-3 col-sm-4 sidebar">
<div class="title-region">
<a href="">Current Page</a>
<svg class="down-arrow mobile-only" width="17px" height="10px">
<use xlink:href="#down-arrow"></use>
</svg><!--end hamburger-->
</div><!--end title-region-->
<div class="mobile-zipped">
<ul class="sidebar-block children">
<li><a href="">Child One</a></li>
<li><a href="">Child Two</a></li>
<li><a href="">Child Three</a></li>
</ul>
<ul class="sidebar-block siblings">
<li><a href="">Sibling One</a></li>
<li><a href="">Sibling Two</a></li>
<li><a href="">Sibling Three with a super long title</a></li>
<li><a href="">Sibling Four</a></li>
</ul>
</div><!--end mobile-zipped-->
</div><!--end sidebar-->
CSS:
.sidebar {
position: relative;
/*width:270px*/
height: auto;
display: inline-block;
/*margin-right:60px;max-width:25%*/
}
.sidebar .title-region {
position: relative;
height: auto;
background: #005DAA;
width: 100%;
padding: 15px;
}
.sidebar .sidebar-block {
padding: 15px;
}
.sidebar ul {
list-style-type: none;
}
.sidebar .down-arrow {
float: right;
margin-top: 8px;
fill: #00305e;
}
JS is included in the fiddle. Any help is much appreciated!