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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:03:26+00:00 2026-06-05T02:03:26+00:00

I have a page that loads a complicated set of forms. In this set

  • 0

I have a page that loads a complicated set of forms. In this set of forms, there are password fields. These password fields have show/hide toggle switches which, when any of them are clicked, ALL the password fields are replaced with equivalents of themselves in the DOM with their types toggled between “text” and “password” to facilitate the show/hide effect. To be clear, the original input is replaceWith()’ed a brand new input with the same attributes, including ID, but with different type attributes.

The problem is when the toggle occurs, global handles I had previously made in jQuery selectors (such as $(‘#password_field_id’)) no longer map to the password fields.

Is there a jQuery function that you can run on a selector that will RE SELECT its original CSS selector from the current DOM?

The function that replaces the inputs is as follows:

function TogglePasswordHide()
{
    var show = false;
    if ($('#basic_pass_24').attr('type') == 'password')
    {
        show = true;
    }

    $('input.password_input').each(function()
    {
        var sDisabled = '';
        if ($(this).is(':disabled'))
        {
            sDisabled = 'disabled="disabled"';
        }

        if ( show ) // show the password
        {
            $(this).replaceWith('<input type="text" '+sDisabled+' class="password_input" id="'+$(this).attr('id')+'" value="'+$(this).val()+'">');
            show_password.text('hide');
        }
        else // hide the password
        {
            $(this).replaceWith('<input type="password" '+sDisabled+' class="password_input" id="'+$(this).attr('id')+'" value="'+$(this).val()+'">');
            show_password.text('show');
        }
    });
}

…Is there a call I can make during the .each to “reload” the jquery object after the replacement has been made so that my global handles to those same relative inputs will simply update themselves rather than having to redeclare new jQuery objects with the same selectors for each element and overwrite the original handles?

  • 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-05T02:03:29+00:00Added an answer on June 5, 2026 at 2:03 am

    Use event-delegation, and listen for the events on the parent form:

    $("form").on("click", ".password_input", function(event) {
        /* What to do when password input is clicked */
    });
    

    Because this event is bound to the form element, you can add and remove inputs as you wish without having to worry about losing events.

    When you click, or perform some other action, on one of the password inputs, this event bubbles up to the form where it is then evaluated. If the .target matches your selector (in this example, .password_input), the callback function will be invoked and you can react to the event that took place.

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

Sidebar

Related Questions

I have a page that loads content through AJAX. Among this content are some
I have a page that loads an external HTML page into an iFrame. There
I have a page that loads a bunch of scripts to prepopulate dropdowns and
I have a page that loads other pages via Ajax (think frames, except without
I have a sharepoint page that loads six webparts, each one of them consumes
I have a PHP page that loads external content using other PHP files. I'm
I have a .aspx page that loads three separate .ascx controls to represent adding,
I have an asp page that loads a response user=exists everytime I try to
I have a web application that has a page that loads the content from
The Idea I have a main PHP page that loads content in DIV's from

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.