move jQuery code to a function
- by GSTAR
I have the following jQuery code:
$('.show-additional-link').click(function(){
$(this).parent().next().slideDown();
$(this).hide();
return false;
});
HTML:
<div class="row">
<label for="native_language">Select</label>
<select name="native_language" id="native_language">
<option value="">Any</option>
<option value="1">English</option>
</select>
<a class="show-additional-link" href="#">Select Additional Languages</a>
</div>
<div id="additional-languages" style="display: none;">
<a class="hide-additional-link" href="#">[hide]</a>
<div class="row">
<!-- additional language checkboxes -->
</div>
</div>
I would like to move the contents of my jQuery code (within the 'click' function) in to a separate function, as I will need to call it again on page load (after the form is submitted, so that the DIV is shown again automatically).
I'm having trouble with this - can anyone help?