1

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 + '%'} );
1
  • @qamyoncu ya, just came to solution myself. thank u Commented Nov 2, 2014 at 14:22

1 Answer 1

3
var widthCalculator = (100 / breadcrumbCounter.length) * .01;

not

var widthCalculator = (100 / breadcrumbCounter.length) * 1%;

Cannot use % this way...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.