Why is this piece of code here not working?
// Show clothing items sections
function showingSection(e) {
$(e).fadeIn('slow');
$(e).css('display', 'flex');
};
$('#accesories').click(function(){
$('.all-items').css('display', 'none');
showingSection('.accesorie');
// $('.accesories').fadeIn('slow');
// $('.accesories').css('display', 'flex');
});
I am going to be reusing the code that it’s inside the “showingSection” function when I click a certain element and I would like to avoid repeating the code over and over again, I know that I can like a toggle class but I am wondering if this could be achieve the way I am trying it to do.
Does the code you posted work? If not, can you post a link to the full code, so we can take a look?
@RandellDawson, Nop it does not work, I will provide the whole code in a moment but my question is, should the code that I provided work?, because I am not sure if I can target classes using parameters.
I believe it should work as long as you are passing in CSS class names which exist. I noticed you are passing ‘.accesorie’ to showingSection, but you commented out some code which references a class named ‘accesories’. Is that a typo? Also, do you see any error messages showing in the browser’s console when executing this code?
lol, you are correct. Dumb mistake, type error… Thank you.
No problem.
FYI - In case it matters, the singular form of accessories is accessory.
Oh yeah, it matters! Thanks!