Hey guys I'm new to JS and I'm trying to combine some functions I built and add some new functionality, but I'm having a rough go.
<script>
$(".1trigger").click(function () {
$(".1expand").toggle("blind", 100);
});
$(".2trigger").click(function () {
$(".2expand").toggle("blind", 100);
});
$(".3trigger").click(function () {
$(".3expand").toggle("blind", 100);
});
$(".4trigger").click(function () {
$(".4expand").toggle("blind", 100);
});
</script>
<script>
$(".1trigger").toggle(function() {
$(this).animate({ backgroundColor: "#fff", color: '#FD0E35'}, 400);},function() {
$(this).animate({ backgroundColor: "#FD0E35", color: '#fff' }, 400);
});
$(".2trigger").toggle(function() {
$(this).animate({ backgroundColor: "#fff", color: '#00c260'}, 400);
},function() {
$(this).animate({ backgroundColor: "#00c260", color: '#fff' }, 400);
});
$(".3trigger").toggle(function() {
$(this).animate({ backgroundColor: "#fff", color: '#1f293f'}, 400);
},function() {
$(this).animate({ backgroundColor: "#1f293f", color: '#fff' }, 400);
});
</script>
What I want to do is simplify these by combining them and also add the functionality to collapse or undo any of the functions when another one of these is triggered. I'm having a hard time so far.
Thanks all!