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

  • Home
  • SEARCH
  • 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 5981657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:58:29+00:00 2026-05-22T21:58:29+00:00

I have this html: <div id=signbtn> <a id=login-link class=btnsignin title=Login>Sign in</a> </div> Upon successful

  • 0

I have this html:

<div id="signbtn">
<a id="login-link" class="btnsignin" title="Login">Sign in</a>
</div>

Upon successful log in, I am able to change the anchor class to “btnsignout” and the title to “Sign out”. So far so good. And now when I click on the anchor to sign out, the log out page loads into content div, but the anchor title doesn’t change back to “Sign in”. Clicking on it doesn’t do anything. The anchor is dead.

Can someone take a look and let me know what change I need to make to the jquery function. Thanks for all the help!

Here is my jquery code:

$('#signbtn').click(function() { 
    $.each($(this).children('a'), function(){
    if($(this).hasClass('btnsignout')){                     
        $('#signbtn a').attr('name', 'Sign In');
        $(this).removeClass('btnsignout');
        $(this).addClass('btnsignin');
        $("#content").load("../admin/logout.php");      
    }

    })
    return false;
});
  • 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-22T21:58:29+00:00Added an answer on May 22, 2026 at 9:58 pm

    Here’s an example of how I would do this.

    Using “live” makes it easier I think, and this way you can have more than one button in your doc and it would work (some changes would be needed to change all buttons from login to logout, and not only the clicked button).

    Declaring the events functions separately also makes it easier to understand (I think).

    function onSignOutClicked() {
        // Convert the clicked button into a sign-in button
        $(this)
            .attr('class', 'btnsignin')
            .attr('title', 'Login')
            .text('Sign in');
    
        // Exec ajax call to sign out and put result in #content
        $('#content').load('../admin/logout.php');
    }
    
    function onSignInClicked() {
        // Convert the clicked button into a sign-out button
        $(this)
            .attr('class', 'btnsignout')
            .attr('title', 'Logout')
            .text('Sign out');
    
        // Exec ajax call to sign out and put result in #content
        $('#content').load('../admin/login.php');
    }
    
    $('.btnsignout').live(click, onSignOutClicked);
    $('.btnsignin').live(click, onSignInClicked);
    

    Maybe you could make a jQuery plugin of this. This way it would be really easier to apply it on an HTML doc, and you could regroup all functions about signing in and out in this plugin.

    Here’s an example plugin (I didn’t exec this code, there’s probably bugs) :

    // Self executing function, to work in a protected scope
    (function(window, $) {
    
        function LoginManager(contentNode, options) {
    
            // register instance properties
            this.contentNode = contentNode;
            this.options = options;
    
    
            // Convert instance methods to be able to bind them to events
            var _this = this,
                so = this.onSignOutClicked,
                si = this.onSignInClicked;
    
            this.onSignOutClicked = function () {
                return so.apply(_this, arguments);
            };
    
            this.onSignInClicked = function () {
                return si.apply(_this, arguments);
            };
    
            // Attach click events to elements in the HTML doc
            $('.' + this.options.loginBtnCls).live('click', this.onSignInClicked);
            $('.' + this.options.logoutBtnCls).live('click', this.onSignOutClicked);
        }
    
        // Define methods for the LoginManager class
        LoginManager.prototype = {
    
            onSignOutClicked : function onSignOutClicked() {
                // Convert the clicked button into a sign-in button
                $('.' + this.options.logoutBtnCls)
                    .attr('class', this.options.loginBtnCls)
                    .attr('title', 'Login')
                    .text('Sign in');
    
                // Exec ajax call to sign out and put result in #content
                $(this.contentNode).load('../admin/logout.php');
            },
    
            onSignInClicked : function onSignInClicked() {
                // Convert the clicked button into a sign-out button
                $('.' + this.options.loginBtnCls)
                    .attr('class', this.options.logoutBtnCls)
                    .attr('title', 'Logout')
                    .text('Sign out');
    
                // Exec ajax call to sign out and put result in #content
                $(this.contentNode).load('../admin/login.php');
            }
    
        };
    
        // We define the loginManager plugin, if it doesn't already exist
        $.fn.loginManager = $.fn.loginManager || function(options) {
            options = $.extend({}, $.fn.loginManager.options, options);
    
            return this.each(function() {
                new LoginManager(this, options);
            });
        };
    
        // default options for the plugin
        $.fn.loginManager.options = {
            loginBtnCls : 'btnsignout',
            logoutBtnCls : 'btnsignin'
        };
    
    }(this, this.jQuery));
    

    Sorry I had some time to kill 🙂

    Nico

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

Sidebar

Related Questions

I have this html div tag defined: <div style=height:100px; width:100px class=total-title> first text </div>
Say I have jquery code like this: html += '<div class=index>' + item.index +
I have an html like this: <div id=container1> <div class=dragme>drag me</div> </div> <div id=container2>
This is the HTML: <div id=testBlue> <span>hello</span> <span id=testGreen class=testGreen>hello2</span> </div> If I have
I have HTML code like this : <div> <a>Link A1</a> <a>Link A2</a> <a>Link A3</a>
I have this HTML <div id=navContainer> <ul> <li class=selected><a href=#>Home</a></li> <li><a href=#>Services</a></li> </ul> </div>
I have this html: <div class=foo parent> <div class=child></div> </div> with some css: .foo{
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
I have this HTML structure: <div class=start> <div class=someclass> <div class=catchme> <div=nested> <div class=catchme>
I have this html: <div class=portlet-header> Company Information ... <button> some button here </button>

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.