I'm sorry for the general title, but I don't realy know how to call it.
Here is my code, that I want to reduce:
$('.ShowDialogIcon').click(function() {
$('.show_dialog').slideDown('fast');
return false;
});
$('.ShowDialogIcon2').click(function() {
$('.show_dialog2').slideDown('fast');
return false;
});
$('.ShowDialogIcon3').click(function() {
$('.show_dialog3').slideDown('fast');
return false;
});
$('.ShowDialogIcon4').click(function() {
$('.show_dialog4').slideDown('fast');
return false;
});
Now I see, that this is a bit unefective, what I would like to do is:
$('.ShowDialogIcon').showDialog('.showDialog');
$('.ShowDialogIcon2').showDialog('.showDialog2');
$('.ShowDialogIcon4').showDialog('.showDialog3');
$('.ShowDialogIcon4').showDialog('.showDialog4');
And what I've come up with is:
jQuery.fn.showDialog = function(cls) {
$(this).click(function() {
$(cls).show('fast');
});
}
And it doesn't work, can anyone help please?
Thanks, Mike.
.show_dialog2in the current code and.showDialog2in the desired code. Intentional?