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 9126013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:56:18+00:00 2026-06-17T06:56:18+00:00

Here is my code, <style type=text/css> .sample { background:yellow; width:50%; border:1px solid #000; padding:5px;

  • 0

Here is my code,

<style type="text/css">
    .sample 
    {
        background:yellow;
        width:50%;
        border:1px solid #000;
        padding:5px;
        margin:2px;
        color:#fff;
        margin: 5px auto 0;
    }
</style>
<?php 
    for($i=0;$i<=5;$i++)
    {
        if($i == "2") { ?>
            <style type="text/css">
                .sample 
                {
                    background:red;
                    width:50%;
                    border:1px solid #000;
                    padding:5px;
                    margin:2px;
                    color:#fff;
                    margin: 5px auto 0;
                }
            </style>
        <?php } ?>
        <div class="sample">
            <?php echo $i; ?> Sample Testing
        </div>
<?php } ?>

In the above for loop i have to change the division ( sample ) background color to red , when the increment value($i) is "2".

NOTE:

  1. Without change the class name for the division.
  2. JQuery is recommended for this.
  3. Dont use inline styles.

Actually i have implemented one Jquery calender in one of projects. In that calender, users can book their slots (days). So i need to show that booked slots (days) in some different color. But we cant able to edit that default class name in Jquery. So this the sample code, i generated related to that.

Please help me on this, If any useful answer will be really appreciate..

Thanks in advance…

  • 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-17T06:56:20+00:00Added an answer on June 17, 2026 at 6:56 am

    You can use php to give inline style for a specific conditon like yours or you can toggle between different classes

    1) Using php

    <?php 
        for($i=0;$i<=5;$i++)
        {
            ?>
            <div class="sample" <?php if($i == 2){ echo "style='background:red;'"}?>>
                <?php echo $i; ?> Sample Testing
            </div>
    <?php } ?>
    

    Since you are so adamant about using jquery, you can try this way too

    2) Using jquery

    $(document).ready(function(){
       $("div.sample:nth-child(2)").css('background', 'red');
    
    });
    

    Check this DEMO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code <!DOCTYPE HTML> <html> <head> <style type ='text/css'> * { font-family:Arial,
here is my code.. <script type=text/javascript> function clicker(){ var thediv=document.getElementById('downloadoverlay'); if(thediv.style.display == none){ thediv.style.display
Here is my code: <%= Html.TextArea(txtMyTextArea, new { @style = width: 100%; height:100%, @resize=horizontal
I have this div in my code: <div id=advice class=validation-advice style=>some text here</div> Now,
Here is my code: <style> #defCalTree { overflow: scroll; overflow-x: hidden; } </style> and
Here is the code: tinyMCE.init({ mode: textareas, theme: advanced, plugins: autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template, // Theme options
I tried to set up my togglebutton properties layout using style.xml. Here's my code:
i have this simple layout css which provide 3 rows layout css code <style
Here is a portion of my code: var styles:String = .keyword{color: #ff0000;} .comment{color: #00ff00;};
Here is jquery code which hides my table cells with the ID of .style2:

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.