Search code examples
javascriptjqueryhtmlcssremoveclass

Can't get jquery to removeClass from specific div on link click


I have been struggling to figure out what I am doing wrong here with such a simple task. Essentially what I am trying to accomplish is when a user clicks a link, say "edit", it should removeClass "hidden" from a div on that screen so it will display. This isn't working, however. When I click the link, nothing happens.

Here's a simplified version of my code:

<a href="#edit">Edit</a>

<div id="editAccount" class="hidden">
    <p>Content!</p>
</div>

$("edit a").click(function() {
     $("#editAccount").removeClass("hidden");
 });

Thanks for any help!


Solution

  • your selector is wrong, use this one:

    $("a[href='#edit']").click(function() {
        $("#editAccount").removeClass("hidden");
    });