1
I’m trying to turn my clicks into functions, since the code is repeating itself in
https://github.com/rg3915/fs2w/blob/gh-pages/js/main.js
This is the original code:
$("#div1").click(function() {
$("#widget-body1").slideToggle("slow");
});
$("#toggle1").click(function() {
$("#widget-body1").slideToggle("slow");
$('#toggle1').toggleClass(function() {
if ($(this).is('.fa fa-chevron-down')) {
return '.fa fa-chevron-up';
} else {
return '.fa fa-chevron-down';
}
})
});
That’s the code I wanted to make:
function myfunc(par1) {
$(par1).slideToggle("slow");
};
$("#div1").click(myfunc("#widget-body1"));
I found the project on Github and sent a pull request ;)
– Sergio
Thank you @Sergio
– Regis Santos