Tips for clearing the blue color box from inputs and buttons in bootstrap after they are clicked

How can I get rid of the blue color box that appears when clicking on form elements such as inputs, select, textarea, and buttons?

I have tried removing it using CSS but it still persists and is quite annoying. Is there a way to remove this blue box using jquery?

Check out a test link here: http://jsfiddle.net/5kcsn/309/

Here is the CSS code I've used:

input,
input:focus,
input:active,
input:hover
{
  border-color: #ccc;  
  box-shadow:  #ccc;
 border: 1px solid #ccc;
 outline:none;
}

And here is the script I've tried:

$("input, select, textarea, form, button").css("outline", "none");
$("input, select, textarea, form, button").css("box-shadow", "none");

Answer №1

When using Bootstrap, it's important to remember that the styling is based on specific classes applied to form elements. Trying to override these styles with a tag selector may not work as expected. Instead of trying to target input elements like this:

input:focus
{
  border-color: #ccc;  
  box-shadow:  #ccc;
  border: 1px solid #ccc;
  outline:none;
}

It's better to use the appropriate Bootstrap class:

.form-control:focus
{
  border-color: #ccc;  
  box-shadow:  #ccc;
  border: 1px solid #ccc;
  outline:none;
}

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

Strategies for storing component data within an Angular service

Recently, I have implemented a dice game feature using Angular. The outcome of the dice rolls is stored in a TypeScript array and then displayed on the HTML page. However, I have been tasked with persisting these results even if I navigate to another pag ...

Hexagonal design reminiscent of a beehive

I am struggling with implementing a specific layout using grid CSS and I'm open to using flex or any other method. .container { display: grid; grid-template-columns: repeat(auto-fit, 50px); grid-template-rows: repeat(auto-fit, minmax(80px, 80px)); ...

ChakraUI failing to display on the screen

Exploring Chakra UI in my latest project has been an exciting journey for me. I made sure to install all the necessary dependencies and started importing components from the ChakraUI Docs. Initially, I successfully imported and rendered the button feature ...

Listing the dates of the month and comparing them with dates from another month using jQuery

Is there a way to generate a list of dates in a month that includes the dates from other months, similar to how the jquery datepicker with showOtherMonths: true works? I was considering creating a calendar with 7 columns (Sun-Sat) and 6 rows to accommodat ...

What is the best way to switch image position using javascript?

I'm experimenting with creating a function that toggles the image source when clicked - changing it back and forth. <img src="http://images.clipartpanda.com/laughing-smiley-face-clip-art-smiley-face-clip-art10.jpeg" longdesc="http://sm ...

I need assistance with incorporating a datepicker feature using jQuery UI

Can someone please assist me? I am trying to incorporate a datepicker (Jquery UI) and add an additional function in the script for counting, but my understanding of jquery is limited. (My English skills are also lacking, apologies in advance) I would dee ...

What is the best way to horizontally center my HTML tables and ensure that they all have uniform widths?

I'm currently facing an issue where I'd like to center align all tables similar to the 'Ruby Table.' However, I'm unsure of how to achieve this. You may also observe that some tables have varying widths. What CSS rule can I apply ...

Tips for centering content in the middle of a line

How can I center align 3 buttons on a line using CSS and HTML? This is what I have tried so far: 1/ CSS : .center-buttons { display: flex; justify-content: center; } .button { margin: 0 10px; } 2/ HTML: <div class="row"> <di ...

Is it possible to trigger AJAX using an element's ID without any event listener?

If I have the following code: if(cond1Satisfied){ <div id="checkA"> </div>} if(cond2Satisfied){ <div id="checkB"> </div>} Can I make an AJAX call like this? $.ajax({ url: 'example.php', type: & ...

An exception known as NullPointerException arises when attempting to invoke JDBC within a servlet

While running my RegistrationServlet, I encountered an issue when trying to create a Database object. Below is the servlet code snippet: @WebServlet("/register") public class RegistrationServlet extends HttpServlet { private static final long serial ...

The onblur and onfocus events in jQuery may experience some functionality issues when used in the IE browser

Utilizing the onblur and onfocus events to toggle the textbox type as either Password or Text. @Html.TextBoxFor(m => m.FinanceModel.VatNumber, new { @type = "password", @class = "form-control capitalize", maxlength = 30, @onblur = "setTypePassword(this ...

Turn off HTML display for Internet Explorer users

I am looking to implement code that will block certain pages for Internet Explorer users, making it accessible only for Google Chrome and Firefox users. Do you have any suggestions on how I can achieve this or if there are existing solutions available? I& ...

Choose not to alter the display value during keyup and keydown events, while still triggering the change event

$(function(){ $(".cls_user_details select").keyup(function(){ $(".cls_user_details select").val("Profile"); }) }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="cls_user_setti ...

Leveraging Enum with sec:authorize="hasRole(...)" for user authentication in a Spring Boot and Thymeleaf application

Trying to make a change: <div sec:authorize="hasRole('ADMIN')"></div> to: <div sec:authorize="hasRole(${T(com.mypackage.Role).ADMIN.getText()})"></div> However, the above modification is not working. ...

Display issue with loading image in Internet Explorer using jQuery AJAX

I am facing an issue where my page has links on the left and data displayed on the right side. Each time I click on a link, I utilize a jQuery AJAX call to load the corresponding data. To enhance user experience, I display a loading image while fetching th ...

When a string begins with the "<" character, jQuery regex is unable to find a match

I am attempting to check if a string starts with the "<" character, but I am running into issues. The expression works perfectly fine on regex101.com, however, it fails when used in my personal files. When I input a backslash everything works as expect ...

If a checkbox is checked, then the value in the textbox should be multiplied by 0

I'm faced with a challenge involving a non-clickable textbox that is meant to hold a running total. Each time a checkbox is clicked, its value should be added to the total in the textbox. However, I am now struggling to figure out how to perform mult ...

What could be causing my JSON file not to display when the onclick event is triggered?

I am currently learning JavaScript and JSON, as I am enrolled in a class that focuses on these topics. Our latest project requires us to create a JSON file and use a button along with JavaScript to display its contents. I have spent countless hours trying ...

Running the NPM build command results in an error specifically related to an HTML file

I encountered an issue in my AngularJS application when running the command: npm run build -- -prod The error message I received was: ERROR in ng:///home/directoryling/appname-play.component.html (173,41): The left-hand side of an arithmetic operation ...

Executing Controller method from an HTML webpage

I have designed a webpage in Html called SomePage.Html, and I am looking to trigger a method every time someone visits this page. Let's say I have a Controller named DefaultController with a method called - Get() and I want this method to be executed ...