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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:45:14+00:00 2026-05-16T11:45:14+00:00

I have a page with three HTML labels and their corresponding ASP.NET gridviews contained

  • 0

I have a page with three HTML labels and their corresponding ASP.NET gridviews contained within divs. Now while learning jQuery, I am trying to achieve two things:
1. Change the css class of the lables upon mouse hover/out.
2. Slide up/down the grid div upon clicking of the labels.
It looks to be working as expected, but I wish to know if I am doing it the right way.

My complete jQuery code is:

$(function ColorChange(ID) {            
                $("#" + ID).toggleClass("gridLabel");
});
$(function ShowHide(GID) { 
                $('#' + GID).slideToggle('slow');
});

And I am calling these function from onmouseover, onmouseout and onclick events of the label controls passing in the label ID as parameter. As an example:

<label id="lblWebComp" class="gridLabelDefault" onmouseover="ColorChange('lblWebComp')"
                onmouseout="ColorChange('lblWebComp')" onclick="ShowHide('gvDivWC')">
                Web Components
</label>

Kindly let me know if this is the best way to achieve these effects? Don’t I have to right the document ready function in the jQuery code?

Thanks a lot!

  • 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-05-16T11:45:15+00:00Added an answer on May 16, 2026 at 11:45 am

    The standard jQuery style is to bind all your functions from jQuery in document ready, as you kinda guessed already in your question.

    So instead of

    <label id="lblWebComp" class="gridLabelDefault" onmouseover="ColorChange('lblWebComp')"
                    onmouseout="ColorChange('lblWebComp')" onclick="ShowHide('gvDivWC')">
    

    in the html markup you might have simply

    <label class="gridLabelDefault">
    

    and then in jQuery:

    $(document).ready(function() {
        $('.gridLabelDefault').click(function() { // this assigns the click to all elements with gridLabelDefault class
            // here you want to find which grid the clicked label corresponds to, as an example
            // I've used siblings, which you could use if your elements are within a shared parent div
            $(this).siblings('.grid').slideToggle('slow'); // assuming you grid has a 'grid' class
        });
    });
    

    That should hopefully give you an idea of the kind of code structure you should be aiming for, obviously you will need to tweak it to your requirements. The jQuery documentation is generally pretty good.

    Regarding the css toggle, I don’t really see from your example what benefits doing that in jQuery gives you. Just use the hover selector and do it in your css file. If you really want to use jQuery though, you can bind to the hover event in document ready in the same manner as I showed with the click event above.

    $('.gridLabelDefault').hover(
        function () { // this is the mouseOver function
            $(this).addClass('gridLabel');
        }, 
        function () { // this is the mouseOut function
            $(this).removeClass('gridLabel');
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three TextBox controls on the page <asp:TextBox ID=TextBox1 runat=server AutoPostBack=True OnTextChanged=TextBox_TextChanged TabIndex=1>
Are there any html helpers for page navigation. eg. if i have 1000 records
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables tag , page , pagetag With the data below page
Here's the problem: 1.) We have page here... www.blah.com/mypage.html 2.) That page requests a
I have a page that is generated which inserts an HTML comment near the
I have a web page that i have written in mainly HTML. When I
I have a page where there is a column and a content div, somewhat
Is there someway to have a part of the page that renders like a
I have a page using <ul> lists for navigation (Javascript changes the styling to

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.