Struggling to customize radio buttons with Bootstrap?

I used inline styles to try and change the color of two radio buttons, but they are still showing up as blue instead of red or green. Can someone please help me identify what's wrong with my code?

     <!DOCTYPE html>
<html lang="en">

<head>
 <meta charset="utf-8>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head 
         content must come *after* these tags -->
    <title>Ristorante Con Fusion</title>
       <!-- Bootstrap -->
     
      <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-theme.min.css" rel="stylesheet">
       <link href="css/font-awesome.min.css" rel="stylesheet">
    <link href="css/bootstrap-social.css" rel="stylesheet">
    <link href="css/mystyles.css" rel="stylesheet">
    </head>
    <body> <form class="form-horizontal" role="form">

<div class="form-group">
          <label for="btn-group" class="col-xs-12 col-sm-2 control-label">Sections</label>

        <div class="btn-group" data-toggle="buttons">
  <label class="btn btn-primary active">
    <input type="radio" name="options" id="option1" autocomplete="off" style ="background-color:red;" checked > True
  </label>
         
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option3" style="background-color: green;" autocomplete="off"> False
  </label>
</div></div>
</form><!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
    <script>
        $(document).ready(function(){
        $('[data-toggle="tooltip"]').tooltip();
         });
    </script>

</body>

</html>
</body>

     </html>

Answer №1

To change the color of buttons from blue to green, replace the btn-primary class with btn-success, and switch the btn-danger class to red.

Answer №2

The radio button itself is being styled, but the blue color is actually coming from the label that encloses it. To change the color of the buttons, you can modify the styling of the labels like this:

 <label class="btn btn-primary active" style ="background-color:red;">
    <input type="radio" name="options" id="option1" autocomplete="off" checked > True
  </label>

  <label class="btn btn-primary" style="background-color: green;">
    <input type="radio" name="options" id="option3" autocomplete="off"> False
  </label>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Ruby on Rails erb syntax within JavaScript

Working on a Rails app view, I am attempting to use JavaScript to determine the screen size and display different content based on that information. This is what I currently have: <script> if( $(window).width() < 1000){ '<%= @resize = t ...

Using JavaScript regular expressions for email validation criteria

Hey there, I am struggling with Regular Expressions, especially when it comes to client side validation for a specific field. Can you please help me come up with a Regular Expression that would verify if an email address is valid based on these criteria: ...

Extract the initial 7 keys from an object and transfer them to a separate object

Is there a way in JavaScript to create a new object that contains only the first 7 keys of another object? This is the object structure from which I want to extract the data. {"data":[{"id":2338785,"team1":{"id":10531,"name":"Just For Fun"},"team2":{"id": ...

"There is a limitation in the MySQL query where it can only go through

I have a PHP function that is supposed to retrieve and display 30 different pieces of information, but currently, it only echoes one. The webpage I am working on can be accessed at the following link: Here is my PHP Code: <?php // Connect to the datab ...

What is the reason for setting the initial value of a Vue computed property to a Javascript object property?

Can someone please explain why the Javascript object property, data.test, always holds the initial value of the computed property, square? Even after submitting a number in the input field, data.test remains set to 4. On the other hand, the computed proper ...

Keep sensitive information confidential by refraining from displaying values in the URL while using

When attempting to log in using Spring Security with an AJAX call, I noticed that the username and password are being displayed in the URL. For example: /?j_username=s&j_password=s I have been trying to identify my mistake for quite some time now but ...

How can I select a checkbox dynamically during runtime?

I am working on a JavaScript code that needs to add the checked option to a checkbox if it has an id or value of 2 at runtime. I have tried the following code, but unfortunately, I am unable to check the checkbox. Do you have any ideas on how to solve th ...

Unable to save the newly generated data into MongoDB

I'm currently working on a small project where users can generate random hex colors and save them to a database. However, I seem to be encountering an issue as the data is not being saved to the database. My index.js file serves as the main file for d ...

What is the best way to extract numerical data from the second object in a JSON file?

How can I retrieve the data from the second object's tts number (1,152.81) and display it correctly? I attempted to use priceTag.innerHTML = data[0].tts in my javascript file below, but it doesn't seem to be working as expected. Can you help me ...

Ways to trigger various functions upon alteration of minimum and maximum values in a range slider bar

I am currently working on an app that features a range seek bar. My objective is to invoke a method passing the minimum value of the bar if it has been changed, and likewise to trigger another method passing the maximum value if it has been changed. Below ...

Are you interested in creating dynamic tables/models with Sequelize?

Currently, I am exploring a theoretical question before diving into the implementation phase. The scenario is as follows: In my application, users have the ability to upload structured data such as Excel, CSV files, and more. Based on specific requirement ...

The phone number is not able to be clicked on

I have a phone number included in my markup that I would like to make clickable. Here is the code snippet: <h3 class="footer">Need assistance? Call <a href="tel:+180006XXXX">1800 06X XXX</a></h3> However, upon running this code, I ...

What is the method to retrieve the name of a derived class from a base class?

Can we retrieve the name of a derived class from within the base constructor? class Entity { constructor() { // How can we access and log the class name here? console.log('a') } } class a extends Entity {} new a() ...

Steps for placing a menu link at the far right edge of the menu

I'm looking to customize my NAVBAR by adding a Donate Link Menu on the right side, next to the search icon. Can anyone help with this simple task? Thank you in advance! Here is the link to the website: www.clihelp.org Below is the menu code for my N ...

What is causing setTimeout to not function as intended?

I'm having some trouble moving a <div id="box"> whenever my mouse hovers over it. Currently, the element only moves when I trigger the mouseover event on the div itself instead of when my mouse is actually hovering over it. document.getElements ...

What are the steps to retrieve the JSON response from Rally REST API using either JSONP or an HTTP Proxy?

Greetings fellow Stackoverflow members! This is my initial post on this platform, after years of being a regular visitor. Our in-house defect tracking application relies on ASP. Currently, we follow a manual process to transfer all necessary Rally User st ...

Adjust the width of a textarea dynamically as you type by detecting keyup events

Two text areas have the same text formatting. Their IDs are textareaA and textareaB. I've successfully added functionality to resize textareaA on keyup. How can I make textareaB resize its WIDTH while the user is typing in textareaA? Here's wha ...

Can anyone explain to me why my Lazyload feature seems to be malfunctioning?

Has anyone experienced the issue where their lazy load feature is not working properly? Even after copying the code exactly from the lazy load page and using their images for testing, the images still load normally instead of fading in...? Check out this ...

Creating unsightly class names using Node.js

Is it possible to automatically create random and unattractive class names? For example, is there a tool or plugin that can substitute the .top-header class with something like .a9ev within my CSS code? It would also be ideal if the class name in the HTML ...

Having difficulty passing a variable between two different PHP files

When attempting to modify data in the database for a specific user column, I encountered an issue. The code that I created only alters the data for the last user in the database, rather than the current user. For instance: Let's say I am logged in as ...