Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9218953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:59:08+00:00 2026-06-18T02:59:08+00:00

How to shuffle css rule of div id using javascript ternary operator where condition

  • 0

How to shuffle css rule of div id using javascript ternary operator where condition is set into jquery variable “my_color”

jquery:

<script type="text/javascript">
  $(document).ready(function() {
      $("#my_div")
     .removeClass("horizontal vertical")
     .addClass( ['red', 'blue', 'green', 'gray'].indexOf(my_color) != -1 ? 'horizontal' : 'vertical');
});
</script>

As stated above my class shuffles horizontal to vertical for particular color value of "my_color" as condition. for same condition I want to shuffle float of list item from left with horizontal to none with vertical.my css style-sheet contain list item “#my_div li”.

css:

#my_div li{float:left}

And how can I shuffle multiple css for using same ternary conditional operator?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:59:10+00:00Added an answer on June 18, 2026 at 2:59 am

    Is something like this what you mean ?

    <style>
    .float_left { float:left; }
    .float_none { float:none; }
    </style>
    <script type="text/javascript">
      $(document).ready(function() {
          $("#my_div")
         .removeClass("horizontal vertical float_left")
         .addClass( ['red', 'blue', 'green', 'gray'].indexOf(my_color) != -1 ? 'horizontal float_left' : 'vertical float_none');
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added class to to my image using jquery in jquery $('.myimage img').addClass('img_opacity').css({position:absolute,z-index:999,opacity:0})
I'm using the following jQuery code to shuffle the video links on the left
I would like to set the jQuery Isotope shuffle method to to perform an
Anyone have any idea why shuffle() would only return 1 item? when using: $array2
scala> Random.shuffle((1 to 10).toSet) res10: scala.collection.immutable.Set[Int] = Set(5, 10, 1, 6, 9, 2, 7,
How to set conditional logic in SQL query in order to shuffle the precedence?
<!doctype html> <html> <head> <title>JQuery Cycle Plugin - Example Slideshow</title> <style type=text/css> .slideshow {
Possible Duplicate: javascript - shuffle HTML list element order After a little bit of
I want to shuffle an array of elements in JavaScript like these: [0, 3,
I'm attempting to shuffle a deck of cards using the rand() function but for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.