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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:44:45+00:00 2026-05-14T14:44:45+00:00

There is <dl> with padding-top <dl id=posters style=padding-top: 150px;> <dt class=active>text</dt> <dd class=active><a href=#><img

  • 0

There is <dl> with padding-top

<dl id="posters" style="padding-top: 150px;">
<dt class="active">text</dt>
<dd class="active"><a href="#"><img width="150" height="150" src="..." /></a></dd>
<dt>text 2</dt>
<dd><a href="#"><img width="150" height="250" src="..." /></a></dd>
<dt>text 3</dt>
<dd><a href="#"><img width="150" height="350" src="..." /></a></dd>
</dl>

The difference between images – height.

Trying to write a script, which will change a height of the <dl>, when <dd> is clicked.

Height should be taken from the height attribute of the dd img.

Tryed this, but had no luck:

$("#posters dt").click(function(){
        var parent_padding = $("dd").find("img").height();
        $("dd").closest("dl").css("padding-top",parent_padding);
    }).andSelf().addClass("active")});

Thanks.

  • 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-05-14T14:44:45+00:00Added an answer on May 14, 2026 at 2:44 pm

    I’m guessing that the default behavior of the a element is firing and reloading the page.

    Parent should still work, because the event is on the <dd>.

    Try this:

    $("#posters dd").click(function(e){
        e.preventDefault();
        var parent_padding = $(this).find("img").attr("height");
        $(this).parent().css({"padding-top":parent_padding});
    });
    

    EDIT:

    Looking at your code, it is quite different from what you posted.

    There are several issues.

    I don’t think end() is being used properly (not sure though).

    prev() shouldn’t accept a function as an argument.

    Gave up after that.

    Posted code from link provided:

    Just so it is clear, the code example below is not a solution. It is the actual code that you are using (based on the link you provided). I did nothing to correct it. I’m just making the point that it would be extremely helpful if you would post the actual code you’re using in your question instead of a modified version. As it turns out, your modified version in the question eliminated the error(s).

    $("dt").click(function(){
        $(this).siblings()
                 .removeClass("active")
                 .end()
            .prev(function(){
                        $("dd").parent()
                            .css({'padding-top':$(this).find('img').height()});
        }).andSelf().addClass("active")});
        $("#posters dt").fadeTo("fast",.7);$("#posters dt").hover(function(){$(this).fadeTo("fast",.9)},function(){$(this).fadeTo("fast",.7)});
                                                                             $("#posters .toggle a").click(function(){$(this).toggleClass('active');$("#posters dt").toggle();return false});
      }); 
    

    In the future, please post the code you’re actually using. In this case, you modified out the error. Had you posted the actual event handler, you would have had an immediate solution.


    PARTIAL SOLUTION:

    This is the beginning of a solution.

    You were assigning events inside of the click event handler. This is not right, so I just removed them. I’ll consider those to be a separate issue for now.

    This (as far as I can tell) will do what you want with the padding. Please notice that your click event is on the dt and not the dd, since that is how you had it in your code.

    If the event should be on the dd, then change it to #('posters dd').click(... and get rid of next() on the next line down.

    $("#posters dt").click(function(){
        var padding = $(this).next().find('img').attr('height');
        $(this)
            .addClass('active')
            .siblings()
            .removeClass("active");
        $(this).parent()
            .css({'padding-top':padding});
    }); ​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to detect the true border, padding and margin of elements
There are a few ways to get class-like behavior in javascript, the most common
There is a conversion process that is needed when migrating Visual Studio 2005 web
There are two weird operators in C#: the true operator the false operator If
There are two popular closure styles in javascript. The first I call anonymous constructor
There is previous little on the google on this subject other than people asking
There seem to be many ways to define singletons in Python. Is there a
There are numerous Agile software development methods. Which ones have you used in practice
There are several types of objects in a system, and each has it's own
There is a field in my company's Contacts table. In that table, there is

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.