Tips on implementing CSS post jQuery-induced modifications

I am currently working on dynamically adding elements to an HTML page while also implementing the bootstrap 3.2 css.

Below is the jquery function that I am using:

$( document ).ready(function() {
    $(".refresh-btn").click(function (){

        $("<div></div>").attr("class","row new").appendTo('.Item-List');
        $("<div></div>").attr("class","col-sm-3").appendTo('.Item-List .new');
        $("<div></div>").attr("class","panel panel-default").appendTo('.Item-List .new .col-sm-3');
        $("<div></div>").attr("class","panel-headingt").appendTo('.Item-List .row .col-sm-3 .panel-default');
        $("<h3></h3>").attr("class","panel-title").text("Panel title").appendTo('.Item-List .new .col-sm-3 .panel-default .panel-headingt');
        $("<div></div>").attr("class","panel-body").text("Panel content").appendTo('.Item-List .new .col-sm-3 .panel-default');
        $("<button></button>").attr("type","button").attr("class","btn btn-default btn-sm").attr("id","proccesing-btn").appendTo('.Item-List .new .col-sm-3 .panel-default');       
    })
});

The purpose of this function is to replicate and add the following code dynamically:

           <div class="row">
                <div class="col-sm-3">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">Panel title</h3>
                        </div>
                        <div class="panel-body">Panel content</div>
                        <button type="button" class="btn btn-default btn-sm"
                            id="proccesing-btn">
                            <span class="glyphicon glyphicon-chevron-down"></span>
                        </button>
                    </div>
                </div>                  
            </div> 

Although everything seems fine, the issue I'm encountering is that the newly added elements are not applying the css:

Answer №1

There is a typo in the following line:

$("<h3></h3>").attr("class","panel-title").text("Panel title").appendTo('.Item-List .new .col-sm-3 .panel-default .panel-headingt');

Correct .panel-headingt to .panel-heading

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

Selecting multiple items from a grid using the Ionic framework

I am looking to create a grid of category images in Ionic framework, where users can select multiple categories and send their values to the controller. However, I'm unsure about how to make this happen with Ionic framework. Below is the view I curre ...

Curved edges achieved without the need for relative positioning

Can anyone help me with a specific code snippet to achieve rounded corners for this page ? Currently, I am using the PIE.htc file which only works when I declare position:relative; throughout the layout, causing disruptions. Is there a code workaround that ...

Transforming jQuery.ajax post to fetch API

I am currently working on a service that asynchronously calls a REST API. My jQuery code is working fine, but I want to switch to using JS fetch. However, when I try to post the data with fetch, the server responds with an error saying "Missing parameter: ...

The Hidden Power of jQuery: Unleashing the Full Potential of .text()

I'm trying to make two values equal, but it's not working... var rowID = $("#@idSelectObjectGuid").val(); $($(".ls-grid-body tr").children("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="240a64524770454648410a74564d ...

The Facebook JS SDK is causing an XSS error and returning a "user_denied" response, even though the Auth Popup for FB.Login is not being

I currently have a Facebook canvas app located at Previously, I was using an anchor link to direct users to the OAUTH login flow. After implementing the Facebook JavaScript SDK, I followed this logic: 1) Initialization of the FB API FB.init({ a ...

the best way to transfer a JavaScript value to a PHP page

I am experiencing an issue with an undefined function in my PHP page. I have tried everything and it just doesn't seem to work for me. Can anyone please assist me with this problem? <!DOCTYPE html> <html> <head> <scrip ...

Unpredictable jQuery Ajax setTimeout

I have a script that retrieves data from ajax.php and displays it in a div. The intention is for the information to be shown for a period of 3 seconds before hiding the #ajax-content and displaying #welcome-content. Most of the time it works as intended, ...

Issue with Tailwind CSS table header alignment not properly aligning to the right

Currently, I am facing an issue with tailwindcss where the headers in my table are not following the text-right / text-left / text-center directives. If you want to see the problem yourself, here's a link to the fiddle: https://jsfiddle.net/3u2jgqoc/ ...

Unused content in the stylesheet

I am currently referencing my CSS stylesheet in the following way: <link rel="stylesheet" type="text/css" href='@routes.Assets.versioned("stylesheets/main.css")' media="screen" /> The location of the stylesheet is found at /public/stylesh ...

What is the best way to flip the pentagon shape made with CSS?

I need assistance in creating a downward-pointing pentagon shape. However, I am unsure of how to define the points on the shape. #pentagon { margin:70px 0 5px 20px; position: relative; width: 110px; border-width: 100px 36px 0; border-style: solid; ...

Tips for maintaining the activation of a single image button until another one has been selected

I am currently in the process of building a website and using frames, although I understand that div might be a better option. My website is structured with menu.html & main.html, where main.html changes based on which button is clicked in menu.html. menu ...

Adding a JavaScript variable into a Django template tag

This particular situation has been presenting a challenge for me. So far, I have been using query parameters instead of a variable within the {% url %} tag. However, I can't help but wonder if there is a way to achieve this: I am interested in includ ...

Identifying the JS Tree nodes that have been repositioned via drag-and-drop

I'm working with a JS Tree structure that includes drag and drop functionality. Here's the basic code I have so far: $('#using_html_1').jstree({ "core": { "check_callback":true }, "plugins" : ["dn ...

What are the different ways to eliminate the scrollbar in angular, css, js, or html?

I'm a beginner in front-end development and despite searching for a solution, I haven't been able to find an answer. Is there a method to eliminate the scrollbar from my page containing an image? Or are there alternative approaches to maintain a ...

Learn the best way to handle special characters like <, >, ", ', and & in Javascript, and successfully transfer escaped data from one text box to another

I am seeking a way to use JavaScript to escape special characters. I came across a code snippet on this URL: http://jsperf.com/encode-html-entities. It successfully handles <>&, but I have encountered an issue with double quotes ("). The JavaScri ...

Modify the color of the text to be white

How can I modify the code below to change the text color to white? The original code is inspired by this question. I am unsure about how the text color was originally set to blue. .footer-background { padding-top: 20px; padding-bottom: 20px; bac ...

Checking for non-empty values in a jQuery UI DateRangePicker

tl;dr: How can I prevent empty dates from being inputted in jquery-ui-daterangepicker? I am currently utilizing the plugin and encountering difficulties in validating if a date range has been chosen. My objective is to keep the #export_date_range date ra ...

Is there a way for me to view the data transmitted by JQuery to php?

I have this piece of jQuery code. I am curious to see what PHP will output. How can I display that result? <html> <head> <script src="http://code.jquery.com/jquery-latest.min.js"></script> </head> <script> $.ajax({ ...

When clicking, expand the li element to 100% width and move the other siblings aside

I'm looking to arrange li elements in multiple columns with flexibility. https://i.sstatic.net/HJCZu.png <ul> <li class="yellow"> Yellow Block </li> <li class="red"> Red Block ...

Tips for accessing CSS properties on the img tag

I could use some assistance with CSS. I am in the process of creating a tree structure using many <ul> and <li> tags. The issue arises when I have multiple <li> elements with a specific class, each containing an <img> tag. How can ...