Getting rid of an accidental div around an input field that was generated by Bootstrap with the help of

I have been experimenting with creating a slider using Jquery and storing the input in an

<input type="text" readonly>
. Everything was working fine until I tried to place the input inside a popup-window div. This caused an extra div to be created around the input tag, which seems to inherit the CSS of the popup-window div and results in a bulky border around it.

Upon inspecting the elements in Chrome, I noticed this extra div being created. Is there a way to prevent Jquery from creating this unnecessary div or at least remove the inherited CSS to make it invisible?

Here is the HTML code:

<span style='position:absolute; bottom:5px; left:15px;'>
            <a href="#vote" id="vote-button" data-rel="popup" 
                class="ui-btn ui-btn-inline ui-corner-all" 
                data-position-to="window"
                data-transition="fade">
                Vote
            </a>
        </span>
    <div data-role="popup" id="vote" style="width:300px; margin:auto; overflow:none;" class="ui-content">

                <a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right"></a>

                    <br>
                    <button href="#main" class="ui-btn ui-btn-inline ui-corner-all" style="position:relative; width:100%; margin:0 auto">Send</button>
        <p>
          <label for="amount"></label>
          <input type="text" id="amount" readonly style="border:0; color:#f6931f; font-weight:bold;">
        </p>
    </div>

The Javascript/jQuery snippet:

    $( "#slider" ).slider({
  value:100,
  min: 0,
  max: 500,
  step: 50,
  slide: function( event, ui ) {
    $( "#amount" ).val( "$" + ui.value );
  }
});
$( "#amount" ).val( "$" + $( "#slider" ).slider( "value" ) );

I referenced this example for the sliders:
Slider Example
And this example for the popup window: w3schools Popup Example

Codepen.io: Error case

Cheers

Answer №1

UPDATE:

A more efficient method has been discovered, take a look HERE on CODEPEN:

$("#vote-button").click(function() {
     $("#vote").find(".ui-input-text").remove(); 
})

This will eliminate the div surrounding your input box without any hassle.


View a functional demonstration in CODEPEN.

The solution involves removing all classes from the div enclosing the input box like this:

  $("#vote-button").click(function() {

       $("#vote").find(".ui-input-text").removeClass("ui-body-inherit").removeClass("ui-corner-all").removeClass("ui-shadow-inset").removeClass("ui-input-text");

   })

When clicking on the input box, Bootstrap applies a new class called ui-focus. There are two ways to handle it. The first one is using jQuery:

$("#amount").click(function() {
   if ($(this).closest("div").hasClass("ui-focus")) {
         $(this).closest("div").removeClass("ui-focus");
   }
})

Although effective, this method briefly displays the box-shadow and then quickly removes it. Another option is utilizing CSS like this:

.ui-focus {
    box-shadow: none !important;
}

However, be cautious with this approach as it may affect other elements that rely on this class for click effects.

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

Determining the worth of radio buttons, dropdown menus, and checkboxes

I am working on designing a menu for a pizza place as part of a learning project. The menu allows users to select their pizza size from small, medium, and large using radio buttons, and then customize it further with three select boxes where each selection ...

Utilizing the Replace function just once

I am currently using the Avada Theme on Wordpress and I am attempting to use jQuery to translate the social media privacy labels/content. Everything is working smoothly except for one issue. Below is the HTML code: function translate() { jQuery(".fus ...

SVG: organizing objects based on event priority

I am struggling with layering and event handling in an SVG element. Check out the example here: https://stackblitz.com/edit/angular-ivy-rkxuic?file=src/app/app.component.ts app.component.ts import { Component, VERSION } from '@angular/core'; @ ...

What is the correct method to choose an element in jQuery based on the function's id parameter

I'm having trouble deleting an item in my to-do list app. deleteToDoItem: function(id) { $(id).remove(); console.log(id); }, Here is the function that calls deleteToDoItem: function deleteItem(event) { var itemID, splitID, t ...

Functionality of multiple sliders

Is there a more efficient way to handle the fading in and out of sections on a slider? I currently have separate functions for each section, but I'd like to simplify it so that I only need one function for all 100 sections. Any suggestions? $(&apos ...

Controlling icons and images in Django

I have a question regarding the best practice for managing media on my Django site. Unlike most questions that involve confusion with code snippets, this one concerns the dilemma faced by some web developers. Instead of storing all media content in a mod ...

Upgrade your AngularJS Directive to an Angular 2.x+ Directive by using an HTML decorator

Is it no longer possible to utilize Angular directives as what I like to refer to as "HTML decorators"? I found this method extremely useful in Angular 1.x when transitioning legacy applications to Single Page Apps by creating a set of directives to enhan ...

Arranging two divs side by side using CSS:inline-block

Having some trouble getting two divs with a width of 50% each to appear on the same row. If I adjust the width to 49%, they stack in the same row. Any ideas on what might be causing this issue in the code? I'm more interested in understanding the caus ...

Using JavaScript to override a specifically declared CSS style

In the process of working with a database, I come across HTML that includes "spans" colored in different shades. An example would be: <div id="RelevantDiv">the industry's standard <span style="background-color: red">dummy text ever since ...

Guide to playing a gif solely through an onclick event using JavaScript

Below you will find a code that is used to load a gif animation from an array of characters, and then display it within a board class using the image src. I am looking to make the gif animation play only when the displayed gif is clicked. Currently, the ...

Trouble with Styling React-Toastify in TypeScript: struggling to adjust z-index in Toast Container

Currently in the process of developing a React application utilizing TypeScript, I have incorporated the React-Toastify library to handle notifications. However, encountering some challenges with the styling of the ToastContainer component. Specifically, ...

Implementing bloginfo('template_directory') in jQuery for use in the Admin Panel

I've been attempting to customize the contact form 7 database and I need to use bloginfo('template_directory') in jQuery for it. Following suggestions from previous posts, I have tried: Adding a variable in header.php Utilizing wp_localiz ...

Steps to incorporate Ajax into current pagination system built with PHP and Mysql

Greetings! I am a beginner programmer looking to enhance my PHP & Mysql based pagination with Ajax functionality. Despite searching through numerous tutorials, I have been unsuccessful in finding a guide that explains how to integrate Ajax into existin ...

Rendering data in Ionic 2 before the view is loaded

Currently, I am encountering a lifecycle issue with Ionic 2 as I learn it. My goal is to display data only after the API call returns a success response. import {Component} from '@angular/core'; import {NavController} from 'ionic-angular&ap ...

Frontend web designer

Aspiring to become a web developer, I've taken some Django courses. Is there a "Frontend Designer" platform (similar to wordpress) that can create user-friendly templates like html for Django developers? Or are there specialized "Frontend Designers" o ...

Strategies for aligning tooltips with the locations of dragged elements

One of my projects involves a simple drag element example inspired by Angular documentation. The example features a button that can be dragged around within a container and comes with a tooltip. <div class="example-boundary"> <div ...

Customize your jQuery 3.x version by adding Ajax functionality tailored to your

I've been working on creating a custom jQuery 3.x version, but I'm facing the issue of maintaining the functionality of $.ajax even when ajax is not explicitly removed. Below are my build and grunt settings: grunt custom:-css/showHide,-deprecate ...

Excessive Spacing Below Picture

I am trying to position an image and a div directly beneath it, but I am encountering an issue with a visible margin between the two elements. You can view the code snippet here: http://jsfiddle.net/d3Mne/1/ Upon further investigation, I have noticed that ...

The sequence of events in the DOM for jQuery droppable interactions

Running into a dilemma with my listeners. One is the droppable class from jquery UI $("#myDiv").droppable({ drop: function( event, ui ) { console.log('Triggered!'); if (window.draggingMove == true) { alert(&ap ...

Try utilizing a variety of background hues for uib progressbars

Looking to incorporate the ui-bootstrap progressbar into my template in two different colors, background included. My initial idea was to stack two progress bars on top of each other, but it ended up looking too obvious and messy, especially in the corner ...