I am quite new to jquery and was wondering if someone could recommend some ways I could combine these functions together so that the code would be more efficient and slimmed down. I basically have two click functions that do the exact same thing but are targeting two different buttons. Thank you.
$( ".step1 button" ).click(function() {
if ($(".step1 input").is(":checked")) {
$( ".step1").slideUp("slow",function(){
$(".step2").slideDown("slow");
});
} // end if
else{
$("div.error").remove();
$(".step1.step-heading").append("<div class='error'><i class='fa fa-exclamation-triangle'></i> Please make a selection before continuing</div>");
} // end else
})// end click function
$( ".step2 button" ).click(function() {
if ($(".step2 input").is(":checked")) {
$( ".step2").slideUp("slow",function(){
$(".step3").slideDown("slow");
});
} // end if
else{
$("div.error").remove();
$(".step2.step-heading").append("<div class='error'><i class='fa fa-exclamation-triangle'></i> Please make a selection before continuing</div>");
} // end else
})// end click function