Is it possible to "refresh" or "rerun" a jQuery selector after the DOM might have changed?
<p>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.</p>

<p>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.</p>

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

<p>The function that replaces the inputs is as follows:</p>

<pre><code>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('&lt;input type="text" '+sDisabled+' class="password_input" id="'+$(this).attr('id')+'" value="'+$(this).val()+'"&gt;');
            show_password.text('hide');
        }
        else // hide the password
        {
            $(this).replaceWith('&lt;input type="password" '+sDisabled+' class="password_input" id="'+$(this).attr('id')+'" value="'+$(this).val()+'"&gt;');
            show_password.text('show');
        }
    });
}
</code></pre>

<p>...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?</p>
