V
V
Vladik Limonadik2014-11-02 17:08:23
JavaScript
Vladik Limonadik, 2014-11-02 17:08:23

How to pass expression through .css method?

Hello.

There are, for example, 2 li elements.
I do li.length, I get 2.

And I need to write a script that would assign a width in% to other elements (children of li), which would depend on the amount of the element itself or

var breadcrumb = $( '#crumbs ul li a' );
var bradcrumbCounter = $( '#crumbs ul li' );

breadcrumb.css("width", )


And then I don’t know what to write in width. I thought to do like in SASS type:

100 / breadcrumbCounter.length * 1%;

But how would you translate this into JavaScript?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2014-11-02
@knitevision1

breadcrumb.css({width : 100 / breadcrumbCounter.length + '%' })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question