开发者

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开发者_JAVA百科.

  <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


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

h should equal h + 'px'

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


Try:

$(document).ready(function () {

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

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜