简体   繁体   中英

Change jquery function on click

I wrote a function to change the height of container according to its content

function heightChange()
{
var h1 = $("#primary-page .entry-content-pageAbout").height();
var h2 = 550;
var max = Math.max(h1,h2);
$('#content').height(max);
}

and it works on $(window).resize

i want to change the height on click, so i wrote this

$(".entry-content-sublinksAbout a:eq(0)").click(function(){
$(".entry-content-page-holder").animate({top:-420}, 800,'easeInOutCubic');
heightChange();
});

my problem is on click i want to get the function and also want to deduct the top:-420 from the total height of #content it which i just animated on click.

please help

To be honest, I'm unsure what you're asking for here, but is this something that will help?

function heightChange(a) {
    $(".entry-content-page-holder").animate({top:-420}, 800,'easeInOutCubic');
    var h1 = $("#primary-page .entry-content-pageAbout").height();
    var h2 = 550;
    var h3 = a;
    var max = Math.max(h1,h2);
    max = max - h3;
    $('#content').height(max);
}

$(".entry-content-sublinksAbout a:eq(0)").click(function(){
    heightChange(420);
});

$(window).resize(function() {
    heightChange(0);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM