Skip to content

switchClass() removes class if removeClass and addClass params are the same #2158

Open
@gtasker10

Description

@gtasker10

I am using jQuery 3.6.0. Seems to be an undocumented "feature" with switchClass(). If I specify the same class to remove and then add, I get no class. In the following example, I would expect to see class="big":

   <input type="text" id="myInput" class="big"></input>
   <script>
      $(document).ready(function () {
         $("#myInput").switchClass("big", "big");
      });
   </script>

The above generates:

<input type="text" id="myInput" class="">

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions