What I am trying to do is make an accordion of sorts with a triangular bullet which rotates to point down when the <dd>
slides down.
Just to be clear, I want the bullet to animate, not just flip between two images.
I know I can do this with css3 and a little class swapping if the bullets were their own html elements (<img>
's or whatever), but in the spirit of keeping content/style seperation I would prefer to leave the background image.
Another approach would probably be injecting some <img>
's into the dom with javascript, but I would rather an more elegant solution if one exists.
It would be even cooler if it could be done somehow with those cool css triangles I recently learned about.
html
<dl id="accordian">
<dt><a href="#" class="active"> Link to slide down dd </a></dt>
<dd> Text to drop down </dd>
<dt><a href="#"> Link to slide down dd </a></dt>
<dd> Text to drop down </dd>
<dt><a href="#"> Link to slide down dd </a></dt>
<dd> Text to drop down </dd>
</dl>
css
#accordian dt {
background: url(../images/triangleBullet.png) left center no-repeat;
padding-left: 20px;
}
jquery
$(document).ready(function() {
//Thermal Coatings page - Accordian
$('#accordian dd').hide();
$('#accordian a.active').parent().next('dd').show();
$('#accordian a').click(function(){
$('#accordian a').removeClass('active');
$(this).addClass('active');
$('#accordian dd').slideUp();
$(this).parent().next('dd').slideDown();
});
});