Skip to content

Instantly share code, notes, and snippets.

@NickClark
Created June 14, 2011 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickClark/1025240 to your computer and use it in GitHub Desktop.
Save NickClark/1025240 to your computer and use it in GitHub Desktop.
How do you create a jquery plugin that needs to keep state?
$.fn.toggle_field_on_select_value = function(select_input, value) {
toggle = function (){
$select = $(select_input);
$this = $(this);
if($select.attr("value") == value){
$this.slideDown();
}else{
$this.slideUp();
}
}
toggle();
$this.change(toggle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment