Reputation: 3143
I got N of li
.
And an element inside of li that needs to take a width depending on how many li
there will be.
Here's what I get
var breadcrumb = $( '#crumbs ul li a' );
var bradcrumbCounter = $( '#crumbs ul li' );
breadcrumb.css("width", )
breadcrumbCounter.length returns 2.
I was planning to use it like in SASS, for example:
var widthCalculator = (100 / breadcrumbCounter.length) * 1%;
and insert it after "width", so that the width is set depending on the amount of li elements.
breadcrumb.css("width", widthCalculator);
But it doesn't seem to work. Where am I wrong?
UPDATE
Solved:
breadcrumb.css( {width: 100 / breadcrumbCounter.length + '%'} );
Upvotes: 1
Views: 58
Reputation: 6711
var widthCalculator = (100 / breadcrumbCounter.length) * .01;
not
var widthCalculator = (100 / breadcrumbCounter.length) * 1%;
Cannot use % this way...
Upvotes: 3