3

I try to change float attribute of menu item by css. I want when body tag has rtl class , float of menu items set with right I wrote this jquery for do this but must done this change before load page .At the result I want do this work with css .

if ($('body').hasClass("rtl")) { $('#cssmenu > ul > li').attr('float','right');}

Now How to convert this jquery code to css?

2
  • Again just body Commented Oct 26, 2015 at 6:55
  • #cssmenu li{float:right} Commented Oct 26, 2015 at 6:55

1 Answer 1

5

You can use

body.rtl #cssmenu > ul > li {
    float: right;
}

The JS code in question has many errors. Here's one if still interested to use JS.

$('body.rtl #cssmenu > ul > li').css('float', 'right');
Sign up to request clarification or add additional context in comments.

5 Comments

if the body element has id Body would it make the code valid?maybe the body has an id of Body
@Pekka Please see stackoverflow.com/questions/33339473/…, OP want to refer to <body>, check my comment on question
I didnt know about the other question my question is if for example we have <body id=Body></body> isnt the code a correct. I didnt know about the other question so i posted my comment. For clarification.
@Pekka As there is only one body element, it'll work. Did I answer your question, maybe I don't get you
@programmer138200 Welcome! Glad to help :)

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.