Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9132893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:23:32+00:00 2026-06-17T08:23:32+00:00

I have a html view which contains a div with class overlay and a

  • 0

I have a html view which contains a div with class “overlay” and a close button with class “close-overlay”. I have events registered in JS for them like this :

$(".overlay").click(function(e){
    var target = $(this); // overlay div

    target.removeClass("hide");

    return target;
});
$(".close-overlay").click(function(e){
    var target = $(e.target) // close-overlay btn
                            .closest(".overlay"); // overlay div

    target.addClass("hide");

    return target;
});

and I’ve tests in qunit as below :

test("Basic Test", function(){
    equal($(".overlay").click().hasClass("hide"), false, "Overlay Click" );
    equal($(".close-overlay").click().hasClass("hide"), true, "Overlay Hide" ); 
});

The first test is getting passed , but the second one is getting failed. Have no idea why !
Could someone please help ? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:23:33+00:00Added an answer on June 17, 2026 at 8:23 am

    In your second assertion, you are testing that the .close-overlay element has the hide class instead of the .overlay element.

    So your test should be:

    test("Basic Test", function(){
        equal($(".overlay").click().hasClass("hide"), false, "Overlay Click" );
        var closeOverlayElement = $(".close-overlay");
        closeOverlayElement.click();    
        equal(closeOverlayElement.closest(".overlay").hasClass("hide"), true, "Overlay Hide");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a partial view which contains the following snippet: @model Mbrrace.Domain.MbrraceForm <div class=row>
I have a html structure like : <div onmouseover=enable_dropdown(1); onmouseout=disable_dropdown(1);> My Groups <a href=#>(view
I am just new in MVC 3. I have a html view which contain
I have HTML view using 2010 .NET, which I am generating in the report
I have a view and template called index.html. I have a image which is
I have below html code in one of the opensource project. <form action=/wiki/bin/view/Main/Search> <div
So I have a view containing a web view with HTML content. This is
In my rails view(index.html.erb), i have following structure <div> <%= render :partial => create
I have an code segment of view .cshtml page like : @Html.ActionLink(Add Charts of
I have created a simple class which contains three properties ID Name Amount i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.