move jQuery code to a function
Posted
by
GSTAR
on Stack Overflow
See other posts from Stack Overflow
or by GSTAR
Published on 2011-01-07T23:45:45Z
Indexed on
2011/01/07
23:54 UTC
Read the original article
Hit count: 189
jQuery
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?
© Stack Overflow or respective owner