implementing css class in javascript

I've been attempting to utilize a plugin for select functionality, but I'm running into issues with the CSS not applying when I insert the class within JavaScript:

The plugin I want to use via JavaScript:

 $('.search-test').SumoSelect({
    search: true,
    searchText: 'Please enter the appropriate keywords...',
    noMatch: 'Sorry, the data you are looking for is not found, please enter the appropriate keywords, the data you are looking for: "{0}"',
    // up: false
});

JavaScript code snippet:

$(document).ready(function() {
    var count = 0;

    $(document).on('click', '.add', function() {
        count++;
        var html = '';
        html += '<tr>';
        html += "<td>"+"<select class='search-test' id='search-test'><option>a</option></select>" + "</td>";
        html += '</tr>';
        $('tbody').append(html);
    });

    $(document).on('click', '.remove', function() {
        $(this).closest('tr').remove();
    });

    $('#insert_form').on('submit', function(event) {

        var form_data = $(this).serialize();

        if (error == '') {
            $.ajax({
                url: "request/create",
                method: "POST",
                data: form_data,
                success: function(data) {
                    if (data == 'ok') {
                        $('#item_table').find('tr:gt(0)').remove();
                        $('#error').html('<div class="alert alert-success background-success">Success insert the data!</div>');
                    }
                }
            });
        } else {
            $('#error').html('<div  class="alert alert-danger background-danger">' + error + '</div>');
        }

    });
});

Answer №1

Issue resolved! It turns out my mistake was not paying attention to where I placed the version of jquery.min.js

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

The daily scripture quote from the ourmanna.com API may occasionally fail to appear

I've been trying to display the daily verse from ourmanna.com API using a combination of HTML and JS code, but I'm encountering an issue where the verse doesn't always show up. I'm not sure if this problem is on the side of their API or ...

javascript game for reversing an array

in case(po==true){ snake_array.reverse(); var i=0; var c=snake_array[i]; //drawing the head draw_head(c.x,c.y); for(i=1;i<snake_array.length;i++){ //drawing the body var c=snake_arr ...

Experiencing a hiccup in React while attempting to play an mp3 file

My project includes the following code snippet, with an example mp3 file and npm package: https://www.npmjs.com/package/react-sound import React from 'react'; import Sound from 'react-sound'; class CustomSound extends React.Component ...

Is there a way to send an array with data to a different component using react-redux within a Higher Order Component (H

It seems like I'm missing something because I can't seem to find any examples of how to pass an array with data from a Higher Order Component (HOC) to another component. Here is the code snippet: import React from 'react' import NoAc ...

Current page with animated CSS3 menus

I found a cool menu example on this webpage: http://tympanus.net/Tutorials/CreativeCSS3AnimationMenus/index10.html. I want to modify it so that the current page's menu item has a different color from the others. For example, when I'm on the home ...

Developing a JSON structure that is able to be deserialized within a C# environment

While attempting to generate a JSON object that can be interpreted as a C# object, I continually encounter 400 bad request errors when sending it via AJAX. Here's my JavaScript snippet: $.ajax({ type: "POST", url: "LeagueService.svc/Fixtures ...

Combining text output using JavaScript, HTML, and Vue

Can you help solve this challenge of outputting concatenated text from a javascript code? The script in question draws a quarter circle that is proportional to the size of the bar and showcases the value of pi accurate to three decimal places. To display ...

Receiving a JavaScript object from an on-click event and passing it to a function does not allow it to be submitted as part

Appreciate any insights... I handle the submission of a form button click: $('.saveItem').on( 'click', function(e) { submitItemSave(true, e); }); When the user-defined function is called on click, the event, e, is passed in: func ...

Warning: Fastclick alerting about an ignored touchstart cancellation

Having an issue with a double popup situation where the second popup contains selectable fields. Below is the code snippet I am using to display the second popup: $("#select1").click(function(e) { e.stopPropagation(); var tmplData = { string:[& ...

Looping through ng-repeats, extracting checked checkbox values in Angular

I am currently dealing with multiple nested ng-repeats in my project, and the third level down consists of a group of checkboxes. Initially, I receive an array of options for these checkboxes, which I handle with the following code snippet: <div class= ...

Make a call to a URL in Symfony2 with JavaScript (AJAX)

I have developed a Symfony2 RESTful webservice prototype that is still a work in progress. I am looking for guidance on how clients can send JSON data or consume JSON data from this webservice. Essentially, I need examples of how to send requests or post d ...

Prioritizing tasks, always giving a call once they are completed

I am trying to populate an HTML snippet with data from Firebase. Here is the JavaScript code I wrote to achieve this: members.forEach(el => { console.log(el) table_number++; console.log("forEachMember" + table ...

Utilizing browser local storage in web development

Currently, I am in the midst of working on an e-commerce platform, a project that holds significant importance for me as it marks my debut into major projects. For the first time, I am delving into the realm of local storage to manage basket data such as q ...

The issue of undefined database columns arises when attempting to transmit data from an HTML form to a MySQL database via Express

My primary objective is to develop a RestAPI using Node.js and test it in a small HTML application. With the guidance of my instructor, I successfully created the RestAPI based on an example and customized it to work with my own MySQL database. Testing ea ...

Unable to expand Bootstrap navbar due to collapsing issue

I recently implemented a collapsed navbar on my website using bootstrap. However, I'm facing an issue where it does not open when clicking on the hamburger menu. After researching various solutions for this problem and trying them out, none of them s ...

Adding an active class to a link tag depending on the current URL and custom Vanity URLs - here's how!

I have a functioning code snippet, but it seems to be missing a crucial part when dealing with URLs such as www.mysite.com/home/. It works perfectly fine if the URL ends with index.aspx, like www.mysite.com/home/index.aspx, but fails when that part is omit ...

Tips on how to connect a single reducer function to trigger another dispatch action

In my React project, I'm utilizing a Redux-Toolkit (RTK) state slice that is being persisted with localStorage through the use of the redux-persist library. This is a simplified version of how it looks: const initLocations = [] const locationsPersist ...

What is the process by which Twitter constantly refreshes and updates your timeline?

Thank you for taking the time to read this. We are in the process of creating a web application and are exploring ways to update counters and information on the client side without relying on scheduled JSON updates. While timeouts can work, we are curious ...

Top approach for accessing data through a Factory function in Angular

Seeking guidance on the most effective method for fetching data from a local JSON file and managing the response. The plethora of options found on Stack Overflow has left me with conflicting thoughts, as different approaches yield similar results without c ...

Discover the Location and Sign Up for Angular2+ Service

I'm currently using the Google Maps API to retrieve a user's geoLocation data, including latitude and longitude. My goal is to pass this information to a web API service in order to receive JSON output of surrounding addresses. I have implemented ...