I would be grateful if you help with this thing, I can't resolve. I am trying to create a function: "if any section has class "active" => take this section's id then add it to body as a class element otherwise remove"
This the code below, but it's not working properly or when I scroll to next section new class is not being added and previous one removed.
<body class="">
<section id="home" class="active">
</section>
<section id="about" class="">
</section>
</body>
if ($('section').hasClass('active')) {
var dataSection = $('section').attr('id');
$body.addClass(dataSection.replace('#', '') + '-active');
} else {
$body.removeClass('home-active');
}