Jquery how to run a function only if condition is true
<p>I have a function that check if CSS value exists,
the problem is that I need the function to work only when the CSS class exists,
currently the function running all the time because I'm using else condition (that need to re do the if condition).</p>

<pre><code> //use for @media only screen and (max-width: 767px) detection    
 $(window).resize(function(){
    if ($('#mobile-view').css('visibility') === 'hidden') {
        $("#product-gallery").insertAfter("#product-info");
    }
     else { 
         $("#product-info").insertAfter("#product-gallery");
    }
 });  
</code></pre>
