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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:20:27+00:00 2026-05-28T18:20:27+00:00

I am trying to Expand/Collapse a DIV . I am using a function to

  • 0

I am trying to Expand/Collapse a DIV. I am using a function to pass in the height I want it set to but it is not expanding or collapsing the DIV. Does anyone have any idea on what I have done wrong? JSFiddle

<html>
<head>
<style>
.podTitles{
    float:left;
    clear:none;
    font-size:12px;
    font-weight:bold;
    color:#3A3938;
    line-height:23px;
    margin-left:10px;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type='text/javascript'>
function changeheight(heightval) {
            var heightset = heightval + 'px';
            if(this.text == 'more')
            {
                $('#overviewtext').animate({ 'height': heightset }, 600);
                $(this).text($(this).text() == 'more' ? 'less' : 'more');
            }
            else if(this.text == 'less')
            {
                $('#overviewtext').animate({ 'height': '150px' }, 600);
                $(this).text($(this).text() == 'more' ? 'less' : 'more');
            }

        };
</script>
</head>
<body>
<div style="background-image:url('Images/RedPodHeader.jpg'); background-repeat:no-repeat; width: 360px; height:23px; background-color: red;">
<span class="podTitles">Overview</span>
<span style="float: right; padding-right: 10px;"><a href="javascript:;" onclick="changeheight(250);"id="morelink">more</a></span>
</div>
<div style="height: 150px; width: 338px; padding: 10px; border-bottom: 1px solid silver; border-left: 1px solid silver; border-right: 1px solid silver;" id="overviewtext"> </div>
</body>
</html>
  • 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-28T18:20:29+00:00Added an answer on May 28, 2026 at 6:20 pm

    Couple of changes in your script, DEMO here

    function changeheight(heightval, _this) {
        var heightset = heightval + 'px';
        var thisText = $(_this).text() ;
        if (thisText == 'more') {
            $('#overviewtext').animate({
                'height': heightset
            }, 600);
            $(_this).text((thisText  == 'more') ? 'less' : 'more');
        }
        else if (thisText  == 'less') {
    
            $('#overviewtext').animate({
                'height': '150px'
            }, 600);
    
            $(_this).text((thisText  == 'more') ? 'less' : 'more');
        }
    
        return false;
    };
    

    Markup change – added this as an argument to the fxn call,

    onclick="return changeheight(250, this);"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make my DIV's height expand to it's child elements. I
I'm trying to expand and collapse a <div> by clicking some text inside the
I am trying to toggle text when I click to expand/collapse a div. I
Trying to create collapsible / expandable divs using jQuery, but it's not working for
I want to be able to expand/collapse a menu, I can do that, but
I am trying to find a universal way to expand most if not all
I am trying to alter the button text for a expand/collapse button. Basically, a
I'm just trying to find a way to control the expand / collapse of
I've added some expand/collapse functionality to a table with jQuery and I'm now trying
I'm writing an MVVM configuration interface, and I'm trying to implement an expand/collapse all

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.