Tips for styling JavaScript code within an HTML document

I have developed a word completer using Bootstrap for styling, but I am facing issues in the output. The program is built using jQuery and JavaScript, and the results are displayed in a list format. However, I am unsure how to resolve this problem.

https://i.sstatic.net/RnrO8.png

Below is the code snippet:

word_finder.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Autocomplete Sentences</title>

  <!-- Libraries -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>



  <script>
  $( function() {
    var availableTags = [
      "Apple",
     ...
      "Python",
      "Ruby",
      "Scala",
      "Scheme",
      "Türk Hava Kurumu Üniversitesi"
    ];
    $( "#tags" ).autocomplete({
      source: availableTags
    });
  } );
  </script>
</head>
<body>


<div class="ui-widget">
    <h1 style="color: purple;"> Word Finder </h1>
    <br>
  <p class=" lead text-primary">Welcome. As you start writing, suggestions will start to appear. </p>
  <label for="tags">Start typing </label>
  <input id="tags" class="form-control" style=" position: center;">
</div>

</body>
<style> ... <style>
</html>

Answer №1

When utilizing jQuery autocomplete, it will generate auto complete tags right after your form input:

<input id="tags" class="form-control" style=" position: center;">

The generated Tags HTML are as follows:

<ul id="ui-id-2" tabindex="0" class="ui-menu ui-widget ui-widget-content ui-
   autocomplete ui-front" style="display: block;top: 32px;left: 
   50.6875px;width: 170px;">
   <li class="ui-menu-item"></li>
</ul>

You can customize the styling of the ul dropdown by using any of the following classes:

Choose a class from this list for styling:

ui-menu ui-widget ui-widget-content ui-autocomplete ui-front

To style the li elements, make use of the "ui-menu-item" class:

<style>
.ui-autocomplete {
   background-color: red;
}
.ui-autocomplete .ui-menu-item {
   color: #FFF;
}
</style>

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

Refreshing the database with new information from an HTML table

Presented below is a table structure: <table id="skuTable" role="grid"> <thead> <th class="skuRow">Order</th> <th class="skuRow">Machine</th> <th>Fab. Date</th> <th cl ...

Attempting to retrieve access token for Paylocity Web API in Node.js, encountering the issue of receiving an "invalid_client" error message

I've been attempting to retrieve the access token for the paylocity API. I can successfully obtain it through postman using the client id and client secret, but when I try to do so with Node.js, I receive the message {"error":"invalid_client"}. Below ...

Illuminate the nodes as I sketch the link in GOJS

I've been attempting to outline all potential nodes when creating a new connection, but haven't had much luck. My goal is to accomplish something along these lines: https://i.sstatic.net/R6jbV.png I experimented with event listeners, bu ...

What is the best way to extract information from a .txt file and transform it into an integer format?

I am currently working on a project involving a distance sensor that retrieves data from a Raspberry Pi and displays it on a website. The goal is to have the data stored in a .txt file and then transferred to the website for display. I am seeking assistanc ...

Tips for waiting for an HTML element to load in a Selenium JavaScript testing script

I'm struggling to find a way to wait for an element to load in a javascript selenium test script. The closest thing I've come across is until.elementLocated, but it seems to throw an immediate exception. Is there a method to delay throwing the " ...

How to use JavaScript regular expressions to verify that an input contains more than zero characters

Can someone help me with a simple regex issue? I've tried searching online but couldn't find a suitable example. I'm struggling with regex and just need to ensure that an input contains more than 1 character (i.e. is not blank). My code uses ...

Mongoose failing to persist subdocument

After trying to insert into my collection, I noticed that the sub-document is not being saved along with it. This issue has left me puzzled. This is the scheme/model I am working with: import { Schema, Document, Model, model } from 'mongoose' ...

Tips for making my modal function properly?

I've encountered an issue with adding two modals to my website. The first modal works perfectly fine, but the second one is not functioning as expected. When I click on the button for the second modal, the background dims as it should, but the modal i ...

Could it be an issue with Jquery? Maybe it's related to AJAX reload, or possibly just a case

Utilizing the following Jquery : $('#resultstable').on('click', 'tbody tr', function() { alert("helloworld") $('#resultstable tr.Selected').removeClass('Selected'); $(this).addClass('Selected'); ...

What is the best way to showcase the reading from a stopwatch on my screen?

Working on these codes has been quite a challenge for me. I have recently embarked on a JavaScript journey as a beginner and attempted to create a stopwatch project. However, it seems like I may have missed the mark with the logic or implementation somewhe ...

AngularJS directive failing to execute

Check out this directive: app.directive('changeImage', function() { return { restrict: 'A', link: function(scope, element, attrs) { alert('here'); $(element).hover(function() { ...

Sending JSON data along with sendFile() in Node.js and Express done right

After setting up a Node.js server with Express and routing, I am faced with the challenge of passing JSON data onto a specific page ("/users/id") while using sendFile(). While I could make an AJAX request on page load to retrieve the data separately, I am ...

Utilizing a combination of HTML, AJAX, and PHP, transfer an HTML input array via AJAX to a PHP webpage

Despite trying numerous similar solutions, none of them have proven effective for my issue. Within a form, users can input an unspecified amount of select options that can be added as needed using AJAX. My goal is to post this array to a PHP page via AJAX ...

What steps should I follow to make a dynamic carousel card with Bootstrap that adjusts to different screen sizes

My goal was to design a Bootstrap card with an embedded 'slideshow'. The idea was to use the second page to provide more information about the content on the first page. While editing this on the web, I managed to create a satisfactory product () ...

Accessing and updating the value of an element within a modal using Ionic Js and Angular JS

In order to update a modal's internal element value upon clicking an external button, both elements reside in different sections with separate controllers. The challenge is passing the button's value from mainCtrl to modalCtrl. <div id="exter ...

Designing a sleek border for form input fields

Seeking assistance in finding a solution as my extensive online search has been unsuccessful. Currently, I have this code to style my form labels: label { display:inline-block; height: 15px; width: 350px; float: left; padding: 5px; ...

What is the best way to obtain the output of a JavaScript function on the server side?

I'm dealing with a JavaScript function that returns an array in this particular format: <script type="text/javascript"> function looping() { var column_num = 1; var array = []; $("#columns ul").not(" ...

Obtain the coordinates automatically when loading a page using ASP.NET

I'm facing a dilemma. Currently, I am utilizing an ASP.NET web application on Windows. Upon loading the page, dynamically generated ImageButtons are displayed. I am in need of finding the X and Y coordinates or TOP and LEFT positions of each ImageButt ...

What is the method for ensuring that the delete functionality is displayed within the same row?

In my division, there are options for names and deletion. It is displayed on my website as: 1.jpg delete The HTML code for the division is: <div id="files1" class="files"> <b class='dataname' >1.jpg</b> <span cla ...

Is there a way to send data to FastAPI using JavaScript and AJAX?

I am facing an issue while attempting to send data using a request body to my server. I keep receiving an error message that says "value is not a valid dict" with the type_error.dict. The backend, which is built using FastAPI, seems to be functioning prop ...