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

The Archive Base Latest Questions

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

I want to run a toggle function for 2 selectors. I have an element

  • 0

I want to run a toggle function for 2 selectors. I have an element with class .rgstr and another one with class .disable which are my selectors.

Here is my code:

$(document).ready(function(){
    $('.rgstr, .disable').click(function() {
        var clicks = $(this).data('clicks');

        if (!clicks) {
            $('.loginpanel').animate({ right: "0"}, 300, function() {
                $('.lgnreg > div').stop().animate({right:"0"},1200,'easeOutExpo');
            });
            $('.disable').css("display","block");
        } 
        else {
            $('.loginpanel').animate({ right: "-300px" }, 250, 'easeInOutCirc', function() {
                $('.lgnreg > div').stop().animate({right:"-25px"},250,'easeInOutCirc');
            });
            $('.disable').css("display","none");
        }
        $(this).data("clicks", !clicks);
    });
});

HTML :

<div class="disable"></div>
<div class="rgstr">
    <a href="#">Login/Register</a >
</div>
<div class="loginpanel">
<div class="lgnreg">
    <div class="login">
        <form>
            <input type="text" name="lgnusername" id="lgnusername" value="Username" />
            <input type="text" name="lgnpassword" id="lgnpassword" value="Password" />
            <input type="submit" name="submit" id="submit" value="Login" />
        </form>
    </div>

    </div>
</div>

I want when the .rgstr is clicked, .loginpanel be opened and then when we click on .disable, be closed. Now it works, but with 2 clicks. First time I click on .rgstr the .loginpanel gets opened, but then I have to click twice on .disable to close .loginpanel, and same for the next times. How can I fix 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-17T13:06:24+00:00Added an answer on June 17, 2026 at 1:06 pm

    Your 'clicks' data element is only on the element you clicked on, not on both elements.

    So, when you click on .rgstr, only it’s data is updated, not .disable‘s. When .disable is clicked the 1st time, its clicks is undefined, so the 1st if block is ran (just like when you 1st clicked on .rgstr).

    You need to save the clicks variable somewhere where both elements can read/write the same value.

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

Sidebar

Related Questions

i have two lines of javascript here, when the toggle function executes i want
Want to run javascript function from parent window in child window Example I have
I want to run code which needs boost libraries. I built it using CMake.
I want to toggle displaying an image in my program. Here is my code
I have a function that will run if any one of the multiple items
Why this code don't work,when i want run this code vwd 2008 express show
I have written php program and uploaded on server. I want run this program
I want to run wget as follows shell_exec('wget 'http://somedomain.com/somefile.mp4''); sleep(20); continue my code... What
my code: <a href=# onclick=obj.addClass('fliph'); return false;>toggle</a> i want click toggle to obj.addClass('fliph') ,then
I have some code that acts as a click toggle for a menu. 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.