N
N
neytan2018-02-17 10:53:31
JavaScript
neytan, 2018-02-17 10:53:31

.hasClass - what am I doing wrong?

Hello, I have a small script:

<script>
  if ( $('.submenu ul li').hasClass('active') ) {
    function(){
      $('.submenu').addClass('vision');
    }
  }
</script>

The bottom line is this: check for the presence of the class "active" menu items (.submenu ul li) and if there are, assign the class vision (or display: block) .submenu, but something doesn’t work, maybe an error in the script?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
I'm Yoda, 2018-02-17
@neytan

if ( $('.submenu ul li').hasClass('active') ) {
      $('.submenu').addClass('vision');
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question