I'm trying to optimize this repetitive piece of code. I think I need to set subsection hrefhref as a variable and then figure out a way to merge the functions? Not too sure. Thanks!
$(document).ready(function () {
$('#alphabetical').click(function () {
$('.subsection').attr('href', function () {
return this.href + '&sort=alphabetical';
});
});
$('#chronological').click(function () {
$('.subsection').attr('href', function () {
return this.href.replace('&sort=alphabetical', '');
});
});
$('#builtfilter').click(function () {
$('.subsection').attr('href', function () {
return this.href + '&status=built';
});
});
$('#allfilter').click(function () {
$('.subsection').attr('href', function () {
return this.href.replace('&status=built', '');
});
});
});