Hi,
I have been trying to create a little jquery plugin for myself so that I can reuse some helpful multiple button submit code.
This plugin will allow me to have a class as a selector for every button I want to use on a webpage, a class for everything I want to show/hide and set the toggle speed to slow, medium or fast.
The issue I have is that what I want as my default settings ie the p tag and slow are acting as hard coded to the plugin rather than taking the parameter inputs of the function ie area and speed.
This is the code for my plugin:
(function( $ ) {
$.fn.multiButtonClick = function (area,speed) {
var settings = $.extend({
area : 'p',
speed : 'slow'
}, area, speed);
return $(this).click(function() {
$(this).parent().nextAll(settings.area).first().toggle(settings.speed);
});
};
}( jQuery ));
This is the code I have to make use of the plugin as a test when I click my button with the .sh class it should toggle to show/hide the navigation area of my website but instead does the p tag on my webpage:
$(document).ready(function() {
$('.sh').multiButtonClick('#nav','slow');
});
Any help with this would be appreciated.