I have a dropdown menu and I want to verify if the submenu hasClass `in`, then for the closest `ul` that has class `.menu` add class `in`. Here is my code but it adds for all `ul` that has class `.menu` instead closest.

```
<script>
  if($(".submenu").hasClass( "in" )) {
    $(".submenu").closest(".menu").addClass("in");
  }
</script>

```