My coding is working fine, just wondered if there is more tidy way to write jQuery code? I was searching for this internet but cant find examples.
There are three duplicated class name with different selectors having different CSS settings. I would like to know if there is clean coding for this.
if ($(this).hasClass('toggle')) {
$(".toggle > span:first").css({
// something...
});
$(".toggle > span:nth-child(2)").css({
// something...
});
$(".toggle > span:last").css({
// something...
});
}
Is there similar to SCSS way? Like below
.toggle {
span {
&:first-child { // something... }
&:nth-child(2) { // something... }
&:last-child { // something... }
}
}
Thank you for taking time to look into this.