I'm using the click/hide function for my questions and answers page. But when I click on the question to show the answer it jumps back up to the top. What do I need to do to get this to stop.
This is my coding:
Script:
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".sub").hide();
//toggle the componenet with class msg_body
jQuery(".cthrough").click(function()
{
jQuery(this).next(".sub").slideToggle(500);
});});
</script>
CSS:
.cthrough {
display: inline-block;
font-size: 15px;
font-family: 'Anaheim', sans-serif;
text-transform: uppercase;
letter-spacing: 0px;
}
.sub {
display: inline-block;
font-size: 13px;
padding-left: 10px;
}
HTML:
<a href="#" class="cthrough">This is my question</a>
<div class="sub">
This is my answer.
</div>
I have tried converting the a href=# to just a div class but that doesn't make the question clickable. I also tried taking the # out but that didn't help either.