views:

53

answers:

1

I need a solution that will set the heights of two divs whose class = col to the height of the tallest one.

I found a solution here that I have used to implement this: http://www.cssnewbie.com/example/equal-heights/

This is the code that I have placed on my site:

<script language="javascript" type="text/javascript" href="jquery.js"></script>
<script>
function equalHeight(group) {
    var tallest = 0;
    group.each(function() {
        var thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}
$(document).ready(function() {
    equalHeight($("div.col"));
});
</script>

Unfortunately, this does not solve my problem. When I open the Firefox Error Console, it says me "$ is not defined"

$(".col") should not be the problem right? When I run the command $$(".col") in Firebug Console it returns my two columns just fine.

Please help me with this, as it is driving me crazy! Thank you for your help.

+6  A: 

The correct script tag attribute for indicating the location of an external script file is src, not href.

So instead of

<script language="javascript" type="text/javascript" href="jquery.js"></script>

You should use

<script language="javascript" type="text/javascript" src="jquery.js"></script>

Check out this page at W3Schools for more info about the script tag

Markus Olsson
Thank you Markus, as a novice developer I tend to make these really silly mistakes. Glad you pointed it out, it works fine now.
prgmatic
@prgmatic: we've all been there ;) Asking questions and engaging in the community is the best way to learn! I'd be really glad if you could accept my answer though :)
Markus Olsson
Sorry about that, I'm new to the community. Thanks again.
prgmatic