Check for the class in an element
<p>If there is an element with the class <code>myclass</code> in the <code>#main</code> element, I want to alert <code>ok</code> but in my example it always shows <code>no</code>, how can fix this?</p>

<p><strong>Demo:</strong> <a href="http://jsfiddle.net/mF2K6/1/" rel="nofollow">http://jsfiddle.net/mF2K6/1/</a></p>

<pre><code>&lt;form&gt;
    &lt;div id="main"&gt;
        &lt;div class="myclass"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;button&gt;Click Me&lt;/button&gt;
&lt;/form&gt;


$('button').live('click', function (e) {
    e.preventDefault();
    //var copy_html = $('#main').clone();
    //if ($('#main').hasClass('myclass')) {
    if ($('#main').is('.myclass')) {
        alert('ok');
    } else {
        alert('no');
    }
})
</code></pre>
