Javascript toggle using custom attributes
- by Jacob
Can't seem to get this to work for me, can anyone offer me some help?
http://codepen.io/anon/pen/kABjC
This should open and close a section of text based on click, it takes the ID # which is just a digit (1,2,3,4,etc) and using that id targets an id to open and close the section.
Javascript
$(document).ready(function(){
$('.classclick').click(function(){
$('#class'+$(this).Attr('data-id')+"show").show(400);
});
});
HTML
<div class="classes">
<?php foreach ($classes as $class): ?>
<div class="class">
<div class="classclick" data-id="<?=$class['cid']?>">
<div class="class-title">
<?=$class['className']?>
</div>
<div class="class-intensity">
Intensity: <?=$class['classIntensity']?>
</div>
</div>
<div class="class-show hidden" id="class<?=$class['cid']?>show">
<div class="class-inner-content">
<div class="two-thirds">
<?=$class['classDesc']?> </div>
<div class="one-third">
Things To Know:
asdfasd
asdf
afsdadfs
fsda
dfsa
dfsadfsa
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>