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 8362237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:53:47+00:00 2026-06-09T11:53:47+00:00

In the below markup, the #enable button will add a class to the #show

  • 0

In the below markup, the #enable button will add a class to the #show div. This class has a method attached to it that fades in/out the #hidden span.

However, even though the class is added to the #show div, the method attached to the class isn’t triggered.

HTML

<input type='button' id='enable' value='Enable' />

<div id='show'>
Testing.. <span id='hidden'>Testing, 1, 2, 3.</span>
</div>​

JS

$(function() {

    // Adds .testing class after the button is clicked. however..
    $('#enable').click(function() { 
        $('#show').addClass('testing')
    });

    // It will not trigger after .testing class has been added to DIV?            
    $('.testing').hover(function() { 
        $('#hidden').fadeIn(); 
    }, function() {
        $('#hidden').fadeOut(); 
    });
});​

Fiddle to work with: http://jsfiddle.net/jS3nM/

It seems I am missing something conceptually. What is the correct way to handle this?

  • 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-09T11:53:49+00:00Added an answer on June 9, 2026 at 11:53 am

    jQuery does not work like CSS. When you do, $("selector"), it will return a list of elements in the document that match that selector right now.

    You will then operate on those elements with jQuery methods. There is no magic like “class-targeted method” going on.

    You can find add a event listener to document:

    $(document).on({
        mouseenter: function() {
            $('#hidden').fadeIn();
        },
        mouseleave: function() {
            $('#hidden').fadeOut();
        }
    }, ".testing");
    

    document is always found and always exists, and the event listener is added to that. The selector at the end filters out what elements are qualified for the event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sample html markup below <div class=container answer_comments> <p class=comment_text>Hey that's not cool.</p> <p class=comment_attribs>By
I have the below markup that cannot be changed: <div>Some data</div> <span>More data</span> <a>Link
I have my markup structure as below: <div> <div>value1</div> <div>value2</div> <div>value3</div> <div>value4</div> <div class=clear></div>
I am trying to use the xaml below to define a Button that will:
The markup below is used for my jQuery carousel widget. The first div serves
Below is the code from internalRegister method of GCMRegistrar class static void internalRegister(Context context,
I want to know the selected value of the markup below. So that I
I have some plain text file (.xls extension) with next markup (attached below). It's
I have two questions on markup below: <Popup> <Button x:Name=button/> </Popup> Why does VisualTreeHelper.GetParent(button)
Based on the below markup, how (in JQuery) would i select the options that

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.