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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:14:48+00:00 2026-06-18T10:14:48+00:00

Below is a code snippet. I’m attempting to affect the class attribute margin-bottom based

  • 0

Below is a code snippet. I’m attempting to affect the class attribute margin-bottom based on both size of window and position. I’ve gotten this to work in all instances of height, width, etc…but for some reason with margin-bottom, all classes take on the size of whichever of my javascript functions come last. I’m not sure if that makes sense? Code below:

//Javascript
var thisMB = null;
$("#Full").find(".t16").each(function () {
                thisMB = '1.25em';
            });
            $("#Full").find(".t8").each(function () {
                thisMB = '4.4175em';
            });

 $(this).css("margin-bottom", thisMB);

<!--html-->
             <div>      
                  <ul class="tlist">
                        <li class="theTeams t16">1 1upLeft upLeft upLeft </li>
                        <li class="theTeams t16">1 1upLeft upLeft upLeft </li>
                        <li class="theTeams t16">3 1 upLeft upLeft upLeft </li>
                        <li class="theTeams t16">4 1 upLeft upLeft upLeft </li>
                        <li class="theTeams t16">5 1 upLeft upLeft upLeft </li>
                        <li class="theTeams t16">6 1 upLeft upLeft upLeft </li>
                    </ul>
                </div>
                <div>
                    <ul class="tlist">
                        <li class="theTeams t8">1 upLeft upLeft upLeft </li>
                        <li class="theTeams t8">3 upLeft upLeft upLeft </li>
                        <li class="theTeams t8">5 upLeft upLeft upLeft </li>
                    </ul>
               </div>

Basically, my LI will take on the latter javascript function rather than the one the specific class instance they are found for. So the .t16 should have a margin-bottom of (say) 14 and the .t8 should be 42…they both are 42. If I move the order they are both 14.

Ideas?

  • 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-18T10:14:49+00:00Added an answer on June 18, 2026 at 10:14 am
    var thisMB = null;
    $("#Full").find(".t16").each(function () {
        thisMB = '1.25em';   <--- this assigns the same variable over and over again
     });
    $("#Full").find(".t8").each(function () {
          thisMB = '4.4175em'; <--- so does this
    });
    
    $(this).css("margin-bottom", thisMB);   <--- this sets the element to thisMB = the final value.
    

    You are assigning the variable over and over again, but assigning it to “this” outside of the loop. If you want to set the value of the selected element (this), it needs to be INSIDE the each(). loop

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

Sidebar

Related Questions

i am not understanding how below code snippet can be made thread safe. class
For the below code snippet, how do I initialize instances of class Enemy with
i am opening the popup window with below code snippet self.open('myJSPPage','ServicePopUp','height=600,width=800,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes'); Once the window
i have below code snippet in my legacy project DetachedCriteria subCriteria = DetachedCriteria.forClass(Employee.class); subCriteria.setProjection(Projections.distinct(Property.forName
Which code snippet will give better performance? The below code segments were written in
I am using the below code snippet to FTP simple text files from a
Please look at the below code snippet and let me know how the out
I have below code snippet SimpleDateFormat dateFormat = new SimpleDateFormat( yyyy-MM-dd hh:mm:ss.SSS); String processedContentDate=2012-04-10
I am very new to asp classic application. The below code snippet is from
Below is a code snippet, where we retrieve a form value. Before further processing

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.