Bri
Bri

Reputation: 739

Any idea why this jquery wouldn't work in IE but works in firefox

I have some code to make sure these two divs with id's content and txtCotent are the same height.

  <script language = "javascript" src = "js/jquery.js"></script>
  <script>
    $(document).ready(function () {

    var h = $('#wrapContent#').css('height');
    $('#content, #txtContent').css('height', h);
                                });
    </script>

Any ideas as to why this wouldn't work in IE? Here is the link ... http://students.uwf.edu/bmg17/workshop/index.cfm

Upvotes: 0

Views: 62

Answers (3)

Riley Dutton
Riley Dutton

Reputation: 7715

Try:

$(document).ready(function () {

    var h = $('#wrapContent').height();
    $('#content, #txtContent').css('height', h + 'px');
});

EDIT: Changed to height() instead of css('height').

Upvotes: 1

Jeremy Battle
Jeremy Battle

Reputation: 1638

As mentioned above because you are using the css() you have to specify a pixel unit for 'height', however, if you use height() instead you can do:

<script>
$(document).ready(function () {

var h = $('#wrapContent#').height();
$('#content, #txtContent').height(h);
                            });
</script>

Without specifying pixels because if no unit is given jQuery will assume pixels. Though can specify a different unit if needed.

Upvotes: 1

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114367

$('#content, #txtContent').css('height', h);

h should equal h + 'px'

You need to express UNITS, in this case, px = pixels.

Upvotes: 2

Related Questions