0

i'm trying to change css of class in my HTML. I'm struggling with that already a long time, and I'm not getting what i'm doing wrong. (I've tried already many versions, but nothing happends)

For example: I would like to change the row height on this following html:

game.html

<div class="game">
<ul class="each" data-bind="foreach: {data: rows, as: 'row'}">
    <li class = "li">
        <ul class="row" data-bind="foreach: {data: row.beads, as: 'bead'}">
            <li class="bead" data-bind="
            currentSide: left,
            drag: bead.drag.bind(bead),
            ></li>
        </ul>
    </li>
</ul>

app.css

.row {position: relative;
max-width: 3000px;}

game.html

$( document ).ready(function() {
    var windowHeight = $( window ).height();
    var rowHeight = windowHeight/5;
    $('.row').css('max-width', rowHeight);
});

5 Answers 5

1
<li class="bead" data-bind="
            currentSide: left,
            drag: bead.drag.bind(bead)">//Missing closing ", Avoided extra ,

And

$('.row').css('max-width', rowHeight + "px");//Add `px`

Demo Fiddle

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

8 Comments

No, just nothing change. On element property i still see 3000 as it was on default
@~Lorenz_i Do you want to change the row height or width? If height see my answer, you have an error
Have included the demo fiddle.
I'm getting the allert, but nothing really happend on my page. 48 hours already on that!
Not. i tryied to copy the example as is from fiddle, still didn't work. i see the hello for all screen width it is not my index.html, its game.html does it matter for some reason?
|
0
$( document ).ready(function() {
    var windowHeight = $( window ).height();
    var rowHeight = windowHeight/5;
   $('.row').css('max-width', rowHeight + 'px');
});

This oughta do it.!!!

You have to append px:

$('.row').css('max-width', rowHeight + 'px');

1 Comment

Same thing happened to me ,my 1st time.. Glad that a friend was there to help me. :)
0

This will not work: $('.row').css('max-width', rowHeight);

This will: $('.row').css({maxWidth: rowHeight + 'px'});

1 Comment

$('.row').css('max-width', rowHeight + 'px') will also work. Instead, $('.row').css({maxWidth: rowHeight + 'px'}) will not work, as maxWidth is not a css property.
0

You're doing:

$('.row').css('max-width', rowHeight); // outputs 100

You have to append px:

$('.row').css('max-width', rowHeight + 'px'); // outputs 100px

Comments

0

To change the height of the row

$('.row').css('max-width', rowHeight);

Needs to be

$('.row').css('max-height', rowHeight + 'px');

You need to append the px to the value and change max-width to max-height

And you need to change this typo: -

drag: bead.drag.bind(bead),

To: -

drag: bead.drag.bind(bead)"

1 Comment

I want to change both of them :) this doesn't work for me for any reason! so annoying! Seems that no matter which change I'm doing, i don't see it on element properties after running the script.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.