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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:45:40+00:00 2026-06-13T17:45:40+00:00

I need a jquery script to add class dynamically to the ‘div’s’ in the

  • 0

I need a jquery script to add class dynamically to the ‘div’s’ in the class row. The class is for setting margins. If there is two div’s in class row add class to first one only, and If there is three ‘div’s’ add class to two avoid third.

So the actual need is calculate the div’s on the ‘row’ and add classes to div other than the last one. Here is my html:-

    <div class="row">
                    <div class="two-col">
                        <h3>Header 2/3 Column</h3>
                        <p>Kidney Cancer Canada is a charitable patient-led support organization established to improve the quality of life for patients and their 
                        families living with kidney cancer. <a href="#">Kidney Cancer Canada</a> advocates for access to netreatments, provides support and information to patients, 
                        funds much-needed research, and works to increase awareness of kidney cancer as a significant health issue. Our goal is to help patients navigate
                        through information about their disease and ensure they have access to new treatment options available to them.</p>
                    </div>
                    <div class="one-col">
                        <h3>Header 1/3 Column</h3>
                        <p>KCC hosts patient and caregiver education meetings and webcasts from locations all across canada. Atttending meetings in-person provides an 
                        excellent oppurtunity to meet other kidney cancer patients, caregivers, and healthcare professionals</p>
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="row">
                    <div class="one-col">
                        <h3>Header 1/3 Column</h3>
                        <p>KCC hosts patient and caregiver education meetings and webcasts from locations all across canada. Atttending meetings in-person provides an 
                        excellent oppurtunity to meet other kidney cancer patients, caregivers, and healthcare professionals</p>
                    </div>
                    <div class="one-col">
                        <h3>Header 1/3 Column</h3>
                        <p>KCC hosts patient and caregiver education meetings and webcasts from locations all across canada. Atttending meetings in-person provides an 
                        excellent oppurtunity to meet other kidney cancer patients, caregivers, and healthcare professionals</p>
                    </div>
                    <div class="one-col">
                        <h3>Header 1/3 Column</h3>
                        <p>KCC hosts patient and caregiver education meetings and webcasts from locations all across canada. Atttending meetings in-person provides an 
                        excellent oppurtunity to meet other kidney cancer patients, caregivers, and healthcare professionals</p>
                    </div>
                    <div class="clear"></div>
                </div>
  • 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-13T17:45:41+00:00Added an answer on June 13, 2026 at 5:45 pm

    If you don’t want to apply that class to your divs with class clear then you can use this

    $('div.row').find('div').addClass('yourclass').not(':last-child,.clear');
    

    Or

    $('div.row').find('div').addClass('yourclass').not(':last-child');
    

    Live Sample

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

Sidebar

Related Questions

I need a jQuery script that will add a class when the user is
I need a jquery script section that checks to see if the first digit
I need to show for every link, dynamically some text with Java-Script (jQuery). The
I have a 3 div's, the jQuery script adds a class when a div
I will need a Jquery script for a table sliding effect just like image
I need help getting a Grease Monkey with JQuery Script to run on a
I am writing a greasemonkey script. The site is using jquery, i need a
Here's my issue - I need to dynamically download several scripts using jQuery.getScript() and
I need a jquery slideshow with div popup i want to show my image
I am trying to add two jquery plugins files to my application. When a

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.