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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:42:46+00:00 2026-06-11T23:42:46+00:00

I have a site with mutliple forms, and I would like to, for a

  • 0

I have a site with mutliple forms, and I would like to, for a specific form, loop through and manipulate the classes on divs and inputs.
I can get the form id with –

var thisForm = $(el).closest('form');
var myId = thisForm[0].id

But then I am not sure how to loop through specific classes.


Example:

for each input with “class1” I want to change it to “class2“

and

for each div with “class3” I want to add “class4“


Any help would be greatly appreciated.

  • 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-11T23:42:47+00:00Added an answer on June 11, 2026 at 11:42 pm

    Should be as simple as this

    var thisForm = $(el).closest('form');
    $('input.class1', thisForm).removeClass('class1').addClass('class2');
    $('div.class3', thisForm).addClass('class4');
    

    See this example http://jsfiddle.net/dXrN8/2

    It’s jQuery, so you don’t need to loop to do these things, actions happen on everything your selector matches.

    What we are doing is finding the form, and assigning it to thisForm.

    Then use that to scope our selectors in the next two lines.

    Then select all input.class1 elements and remove class1 and add class2.

    Then select all our div.class3 elements and add class4.

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

Sidebar

Related Questions

I would like to have in the registration form in my site an interface.
I have a site where I would like to let users select multiple images
I have a web site (ASP.NET, no MVC) with multiple web forms for filling
I have multiple divs on the site! for example <div id='id_111232'>Some text</div> <div id='id_111233'>Some
I am sending a GET request to a site and would like to know
I have an existing ASP.NET application that implements Forms Authentication site-wide. The application is
I currently have a site where different users can login, and depending on their
i have a web site that uses forms authentication. the problem is that i
I use Mechanize to loop through a table, which is paginated. I have a
I am working on creating a Web site like www.hipmunk.com in ASP.NET web forms.

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.