You have a couple errors in your jQuery code. You need to use width()
instead of width
, as it is a function call. Also, you are not selecting menu items when you assign count
, you are only selecting the #menu
.
function resizeButtons() {
var count = $("#menu .item").length;
var itemwidth = $(window).width();
itemwidth = itemwidth / count;
$(".item").css(
"width", itemwidth
);
}
You also need to set display:inline-block
or display:block
on your anchors, so that you can affect the width
.
a { display:inline-block; }
Note: You will also need to account for the padding, etc. on your menu items to get the proper result.