0

I'm trying to add

.km-android div.km-view {
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
}

when a specific condition is meet in javascript.

I've tried adding

$('.km-android, div.km-view').css('-webkit-box-direction', 'normal');       
$('.km-android, div.km-view').css('-webkit-flex-direction', 'column');

but that isn't working any suggestions would be great

Thanks

3
  • try $('.km-android div.km-view') - no , Commented Jan 16, 2014 at 15:16
  • I've tried that to that doesn't seem to work either. Thanks Commented Jan 16, 2014 at 15:18
  • Why not $('.some-element').addClass("my-css-class") Commented Jan 16, 2014 at 15:18

3 Answers 3

1

In your JS you have , which doesn't appear in CSS. Try with:

$('.km-android div.km-view').css('-webkit-box-direction', 'normal');       
$('.km-android div.km-view').css('-webkit-flex-direction', 'column');

or even simplier:

$('.km-android div.km-view').css({
    '-webkit-box-direction': 'normal',
    '-webkit-flex-direction': 'column'
});

However Nick R has right - put this CSS in another class and just add this class to the element if met conditions, so:

.met-conditions {
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
}

and JS:

$('.km-android div.km-view').addClass('met-conditions');
Sign up to request clarification or add additional context in comments.

Comments

0

Try :

$('.km-android div.km-view').css({'-webkit-box-direction': 'normal','-webkit-flex-direction': 'column' });  

Comments

0

Remove the comma from the jQuery selector. You can also use camel case properties:

$('.km-android div.km-view').css({
    webkitBoxDirection: 'normal',
    webkitFlexDirection: 'column'
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.