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 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

<input type=text id=title /> <input type=button id=save_post class=button value=Submit /> <div id=map style=margin-top:10px;></div> For
I have the following span <SPAN style=border:solid;TEXT-ALIGN: right; FONT-STYLE: normal;width:100px; padding-RIGHT: 50px; DISPLAY: inline-block;PADDING-TOP:
Say my css looks like so: #StoreIndexMain .LeftSideControl { padding-top: 35px; background-color:#FFFFFF; width:78px; float:left;
I have code like this: <div class=ui-widget> <ul style=list-style-type: none; padding-left: 0; id=menuList> <li>
Below is some CSS code. .form-field {min-height: 20px; margin-bottom: 10px; padding-top: 4px; width: 80px;}
overflow:auto; margin: 0 auto; padding-top:20px; min-height: 100%; border: 1px solid black; background: #E8E8E8; -moz-box-shadow:
First, the screenshots As you see, although i explicitly described the height, padding-top, etc,
There is an inner div of fixed width and variable height contained by an
Is there any performance difference between: p { margin:0px; padding:0px; } and omitting the
$('#menu .sub-right').css( 'paddingLeft', $('#menu .sub-left').width() ); nor $('#menu .sub-right').css({'padding-left': $('#menu .sub-left').width()}); ...these work. What

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.