Search code examples
jqueryremoveclassmouseenter

mouseenter and removeClass not working with hidden objects


I have two divs, and I want the second to appear when the first one is hovered over. I've done a similar thing before, but the same code isn't working now.

<div class='button blog'>                 
    <h2>Blogs</h2>
</div>

<ul id='blogs' class='hidden'>
    <p>James</p>
    <p>Jeremiah</p>
    <p>Peter</p>
    <p>Thomas</p>
</ul>

My jquery code is simple so far

$('.blog').mouseenter(function() {
    $('.blogs').removeClass('hidden');
});

I do have the main function setup and a line running the document on the ready mark. I even have some other jquery code that is working, which does basically the same thing, and runs off the same principles. What am I doing wrong?


Solution

  • Since your selecting it via ID you have to use #

    $('#blogs').removeClass('hidden');