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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:45:51+00:00 2026-06-10T18:45:51+00:00

OK so I have a container div that loads some content which is generated

  • 0

OK so I have a container div that loads some content which is generated by php. I don’t know what the height of the content is and it is absolute positioned so the container div doesn’t know how high to be until all the content is there. I collect the the height it needs to be in a php variable and want to use jquery to set the container div to this height but it’s not working yet.

I have put this code near the bottom of the page:

<script type="text/javascript">
$(document).ready(function () {
$("#DynContainer").css({height:<?php echo $containerHeight; ?>px})
});
</script>

It is currently not working but looking at the code the php variable is echoed into it correctly. E.g:

<script type="text/javascript">
$(document).ready(function () {
$("#DynContainer").css({height:440px})
});
</script>

EDIT:

As many have helpfully suggested I needed to provide valid code for the CSS. I have since changed it to generate this code:

<script type="text/javascript">
$(document).ready(function () {
var containerHeight = "440px";
$("#DynContainer").css({height: containerHeight})
});

However it still doesn’t work. The ID reference is deffo correct.

EDIT2:

Looking at the console I get this error:

[15:46:29.460] TypeError: $ is not a function @ http://localhost/serge/?page_id=2045:242

Suggesting jQuery is not loaded, but it’s definitely called at the top of the page. Here is the whole page code: http://pastebin.com/tGadjaRA

SOLVED: it was a noconflict jQuery issue.
Thanks everyone

  • 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-10T18:45:52+00:00Added an answer on June 10, 2026 at 6:45 pm

    Put quotes around the value, since it’s a string:

    <script type="text/javascript">
    $(document).ready(function () {
    $("#DynContainer").css({height:'<?php echo $containerHeight; ?>px'})
    });
    </script>
    

    http://jsfiddle.net/mblase75/GF3EK/

    Alternatively, remove the “px” and the quotes so it’s parsed as an integer (“px” is the default unit):

    <script type="text/javascript">
    $(document).ready(function () {
    $("#DynContainer").css({height:<?php echo $containerHeight; ?>})
    });
    </script>
    

    http://jsfiddle.net/mblase75/GF3EK/1/

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

Sidebar

Related Questions

I have three divs, within a content div. Container width 70%. Within that I
I have some code that when the page loads gets the height of an
I have a base page that then loads content via .load() into a container
I have an animation on a partially hidden div container that will execute when
I have a div that will serve as container to other element, I have
i have a div that i use as a container to fit in footer
Below I have a function that animates a div ( container ) either to
I have a big <div /> container that has an image as a background.
I have some images that are wrapped within containers like this: <div id=swatchcontainer> <div
I have a website that uses ajax jquery and colorbox. Inside the div #content

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.